![]() |
Block functions from being called in URL... - 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: Block functions from being called in URL... (/showthread.php?tid=37446) |
Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]flyenig[/eluser] 1. How can I block functions from being called in the URL but i can call them with JQuery. in this scenario, this method, "_functionname()" wont work when im trying to use AJAX with that function. 2. How can I completely block controllers from being accessed by URL, but only my jquery functions can access them. for example, I have a controller called , "ajax.php". In it is functions that will be called with jquery, i dont want people to access it. Any suggestions? Thanks! Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]Ochetski[/eluser] You can add show_404() function to it or make a new line at your config/routes.php like that: $route['controller_name/blocked_function'] = "home"; This will redirect blocked places to home controller Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]Eric Barnes[/eluser] For CI 1.x you can add this to constants: Code: // Define Ajax Request CI2 now has is_ajax() in the input library. Then in your controller: Code: if (IS_AJAX) Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]Ochetski[/eluser] Omg... misunderstood the question. Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]Eric Barnes[/eluser] [quote author="Ochetski" date="1294709983"]Omg... misunderstood the question.[/quote] It happens ![]() Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]flyenig[/eluser] It didnt work, and im running codeigniter 1.7.2 i added that to the constants.php i added the if (IS_AJAX) in the function, now when im trying to submit my form it gives me a 500 Internal Server Error in firebug Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]flyenig[/eluser] this was the error. and i am using sessions with this function Fatal error: Call to undefined method CI_Session::user_data() in /Applications/MAMP/htdocs/cl/application/controllers/ajax.php on line 369 Block functions from being called in URL... - El Forum - 01-10-2011 [eluser]flyenig[/eluser] i just realized i spelled it user_data(), instead of userdata, lol my bad ill try again and post back with the results |