Welcome Guest, Not a member yet? Register   Sign In
Problem when calling controller method
#11

Hello,

please check your base URL as well as .htacess rules. some server does not support .htacess rules.
Reply
#12

(10-02-2018, 11:58 PM)Pertti Wrote: With AJAX trailing slash could cause problems sometimes, but don't think it's that this time.

You could put die('xxx'); as first thing in your controller method.

If xxx appears when you go to URL, it means routing works, and issue must be with rest of the controller/model code. If xxx does not appear it's either routing or __construct method where you need to dig further.

I also see you have auth as default controller, which makes me think you have some sort of authentication going on?

Putting die('xxx'); didn't work. I still get the same error message when I try to call the method (even directly from the browser address bar). This is my __construct method:

PHP Code:
function __construct() {
 
       parent::__construct();
 
       verifyAccess(true);
 
       $this->load->library([
 
           'AcessoLibrary',
 
           'ReportsLibrary',
 
           'SalesCampaignLibrary',
 
           'ClientsLibrary'
 
       ]);
 
       $this->zip->compression_level 9;
 
   

This is the verifyAccess function:
PHP Code:
function verifyAccess($loginOnly false) {
 
       $ci =& get_instance();

 
       if ($loginOnly == true) {
 
           if (!$ci->session->logged_in) {
 
               redirect('/');
 
               return false;
 
           } else {
 
               return true;
 
           }
 
       } else {
 
           if (!$ci->session->userdata('logged_in')) {
 
               redirect('/');
 
               return false;
 
           } else {
 
               
                $decodedMenu 
= (array)json_decode($ci->encryption->decrypt($ci->session->allowedURIs));
 
               $currentURI $ci->uri->uri_string();
 
               
                if 
(arrayPartialSearch($decodedMenu$currentURI) !== NULL) {
 
                   return true;
 
               } else {
 
                   redirect('/Dashboard');
 
                   return false;
 
               }
 
           }
 
       }
 
   
This function is used to validade if the current user has access to the page they're trying to open by matching the page URI with an provided array, that is sent by the server during the login process. I've removed it from the construct to see if it would change and the error persists. I load some libraries that have the methods that make the API calls. And thats pretty much it.

What bothers me most is that the server answers 404, its not CI's 404 error page.
Reply
#13

(10-03-2018, 05:39 AM)Gurutechnolabs Wrote: Hello,

please check your base URL as well as .htacess rules. some server does not support .htacess rules.

I'm using Azure. It works for everything else. Just some of those methods don't work, while others do work. They're even in the same file.
Reply
#14

Welp, it still doesn't works. I'm still manually changing method names in order for them to work.

I've searched on Azure's settings to see if there was something related to cache, but couldn't find anything relevant. I guess that I'll either have to live with it or find another framework (which was already on the plans).

Thanks for everyone's help. I'll keep trying to find a way to solve this in the meantime.
Reply
#15

If die() in controller didn't work, it means it never reaches the controller method.

You can put it in as first line in __construct - that way you can see if it actually makes it to the controller, if you get output the issue is with something within __construct method.

If that doesn't work, you can put die as first thing in index.php - if you don't get output then the issue must be web server configuration side, because your request is not reaching any parts of CI.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB