![]() |
Controller function not finding $_GET variable for jQuery Autocomplete - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Controller function not finding $_GET variable for jQuery Autocomplete (/showthread.php?tid=18418) Pages:
1
2
|
Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-06-2009 [eluser]Fielder[/eluser] I've been hacking away at this all day and searching manuals and forums... still stuck (although I've found a work-around by NOT using a controller/function url). *Consider all javascripts properly loaded and view setup correctly* My jQuery is Code: $("#storeAutoSuggest").autocomplete("/rtui/codeigniter/index.php/storeform/autocompletestore"); The jQuery plugin documents Quote:For remote data: When the user starts typing, a request is send to the specified backend ("my_autocomplete_backend.php"), with a GET parameter named q that contains the current value of the input box and a parameter "limit" with the value specified for the max option. So in my storeform/autocompletestore controller, I have Code: function AutoCompleteStore() I get "ERROR undefined index: q". I know the jQuery and my form view works, because instead of loading the controller/function as I want above, if I simply load an external .php <like this> Code: $("#storeAutoSuggest").autocomplete("/rtui/codeigniter/system/application/views/include/search.php"); But I want to be able to manage the array, data, and database query calls from inside my controller. Any thoughts? Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-06-2009 [eluser]umefarooq[/eluser] hi you can read about get in the guide http://ellislab.com/codeigniter/user-guide/general/security.html if you want to get the variable use Code: this->input->get_post('q'); This function will search through both the post and get streams for data, looking first in post, and then in get: http://ellislab.com/codeigniter/user-guide/libraries/input.html Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-06-2009 [eluser]TheFuzzy0ne[/eluser] As far as I know, the $_GET array is destroyed, though, unless you enable query strings from within your config.php. Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-06-2009 [eluser]Dam1an[/eluser] If you really desperatly need to use $_GET, you could hack (extend?) the core $_GET is unset in the _sanitize_globals() function in the input class (line 90) You can change the protected array to stop $_GET being unset, but it may have unexpected consequences, but it will stop you from having to change any jQuery code, as it will now have access the $_GET Disclaimer: I take no responsibility for the above and its implications Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-06-2009 [eluser]Fielder[/eluser] I tried $autoInput = $this->input->get('q',TRUE); and then ran $autoInput through the code. Actually I tried Code: echo "foo"; So with that said, I presume it goes back to 'enable_query_strings' set to FALSE. I was hoping to leave that set to FALSE for the security reasons I read in http://ellislab.com/codeigniter/user-guide/libraries/input.html. Do you guys think there is a way to get the q value and leave my config set to FALSE? I did set 'enable_query_strings' to TRUE and it worked successfully. But like I mention, if that's not supposed to be set to TRUE for security purposes I'd rather not. I don't know much about the security features so leaving CI's security intact would be the best for me. Dam1an, you totally lost me and I wouldnt even know where to begin hacking into CI's core code. I'd end up effin' something up. Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-06-2009 [eluser]Fielder[/eluser] Here's the code I came up with that works, while setting the 'query_strings' config file to TRUE. Code: $autoInput = $this->input->get('q',TRUE); Does this look right in your opinion, or a better/simpler way? Can you guys explain how this line of code functions? Code: foreach ($items as $key=>$value) { Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-07-2009 [eluser]TheFuzzy0ne[/eluser] It would really help if you told us where that code actually was... Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-07-2009 [eluser]Fielder[/eluser] Code: <?php Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-07-2009 [eluser]TheFuzzy0ne[/eluser] Yes. I can only assume that that's the format that jQuery expects the return string to be. What were you expecting? Controller function not finding $_GET variable for jQuery Autocomplete - El Forum - 05-07-2009 [eluser]Fielder[/eluser] I think I understand what you are saying, although $ is inside the quotes.... as you said that's probably what jquery is expecting so when it outputs it processes the $XXX variable. I'll see if I can decode some of the jquery plugin. I dont know much about javascript and jquery but maybe I can find something in the sea of code. |