![]() |
autoloading helper library model breake ajax json - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: autoloading helper library model breake ajax json (/showthread.php?tid=64149) |
autoloading helper library model breake ajax json - lanoux - 01-20-2016 Hy, i am facing a really strange issue when using the autoload.php file. if i use the $autoload['helper'] = array('myOwnHelper'); inside the config/autoload.php and i make a jquery ajax request, the json isn't render (no object show in console.log ). But with the same ajax and the loading made inside the controller with $this->load->helper('myOwnHelper'); tadam, all worke fine as it must do (the problem is the same whith autoloading my own model). Someone have see this stuff before? I had this behavior since CI2, it's not new. The only manner i have found to bypass this it's to render the request as html, then trim the response ![]() The other solution it's to load at each page helper and model who normally must be globally initialised. Any help would be appreciated it's since days i try to solve this feature ps: i have join an image of what is passing because i am not so sure of my english for the explanation ![]() RE: autoloading helper library model breake ajax json - Narf - 01-20-2016 Does your helper call get_instance()? If so, that's your problem. RE: autoloading helper library model breake ajax json - lanoux - 01-21-2016 no, i don't call get_instance(), here is the code of the helper PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); and i have the same problem when i try to auto load this model PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); RE: autoloading helper library model breake ajax json - lanoux - 01-21-2016 i have try several things, and no way, each time i make an auto loading the json is not interpreted if i use a construct and put inside the load of helper model library, it make the same behavior if i load them inside the function in the controller it work worst, i am enable to load helper model library inside the ajax controller or it breake the json...i am driving nuts...oblige to make procedural stuff inside the controller this work : PHP Code: <?php this make the json uninterpreted PHP Code: <?php as for the js Code: $.post( exept for this problem of json interpretation all work like a dream, really don't know what i am missing RE: autoloading helper library model breake ajax json - arma7x - 01-21-2016 Use get_instance()->config->base_url() instead of base_url() in your helper. RE: autoloading helper library model breake ajax json - lanoux - 01-22-2016 the url is give by base_url() already, try your solution don't change nothing to my problem, this not empech te json to be not interpretated i have the same problem which is describe here i solve this problem by not loading the model (or library or helper) which cause the breake of the json format. when you looke at the response given when you use $this->load-> is ÿÿÿÿÿÿ{my json well formated} |