ajax request instancing an object controller ? |
Hello,
Is a controller method call by ajax request instancing an object controller ? Suppose that in a view we do a ajax query that calls a method of a controller other than the one allowed to load the view. Is the act of placing this ajax request will instantiate the object controller and therefore wanted to call its default __construct () method before calling the method called by ajax request? Example : - controller A load the view A_b - In view A_b, ajax request calls method search() in a controller B who has __construct() like under, is the variable named 'var' will be initiate all the time or sometimes not ? (that is to say even if the session variable exists on the server). I ask it because in my case sometimes i have the message of end session returns (cf. infra) whereas session is not finished. $this->session->userdata('key') is initiate at the connexion for example ($this->session->set_userdata('key' ,'value')) and then i call many times by ajax function in controller B but sometimes, $var == '' whereas session time is not unfinished. My Controller A (example) PHP Code: class A extends CI_Controller My Controller B PHP Code: class B extends CI_Controller
Yes, an AJAX request will call the controller's constructor. However, you probably need to read through this portion of the user guide:
http://www.codeigniter.com/user_guide/li...oncurrency It's also possible that you are having some other issue related to session handling and AJAX, in which case your best solution may be to move some of the error handling to the client by requiring multiple missed requests before assuming the session has expired (however, if the problem IS a concurrency issue, this could make it worse).
Thank you.
I search about concurrency but it's possible that the problem became from the enterprise where i work because there are some micro-cuts in the network apparently. But i continue to search and review my code. Have a good day. |
Welcome Guest, Not a member yet? Register Sign In |