Unable to load the requested file |
[eluser]nonamez[/eluser]
I just created file /CodeIgniter/application/helpers/my_ajax_helper.php and now want to use it's functions in CodeIgniter/application/controllers/Ajax.php so i use: Code: function __construct(){ But error occurred: Unable to load the requested file: helpers/my_ajax_helper.php What is wrong?
[eluser]CroNiX[/eluser]
Helpers are regular procedural functions, not objects - so there wouldn't be a __construct or parent, or even $this. If you want to use CI within a helper or library, you need to use get_instance() to bring the instance into your function/library. See the "Utilizing CodeIgniter Resources within Your Library" section of the library docs. It would be basically the same for a helper as far as using get_instance().
[eluser]nonamez[/eluser]
no, i am trying to create my own helper file and load it in controller - is it possible?
[eluser]CroNiX[/eluser]
Sure, don't use "MY", which is reserved for extending the native CI core, not your own. rename it to just "ajax_helper.php" and call it like $this->load->helper('ajax');
[eluser]nonamez[/eluser]
i tried it and without my and with my - same error.
[eluser]CroNiX[/eluser]
Sorry, not sure then. Works here. /application/helpers/ajax_helper.php Code: if ( ! function_exists('ajax_test')) //in controller Code: $this->load->helper('ajax');
[eluser]nonamez[/eluser]
Same error: Unable to load the requested file: helpers/ajax_helper.php Where problem might be?
[eluser]nonamez[/eluser]
[quote author="CroNiX" date="1358705173"]Sorry, not sure then. Works here. /application/helpers/ajax_helper.php Code: if ( ! function_exists('ajax_test')) //in controller Code: $this->load->helper('ajax'); If it is possible please upload yours application folder with working own helper somewhere.
[eluser]nonamez[/eluser]
[quote author="CroNiX" date="1358706266"]is your filename lower case?[/quote] yes |
Welcome Guest, Not a member yet? Register Sign In |