![]() |
Calling a controller from javascript? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Calling a controller from javascript? (/showthread.php?tid=13350) |
Calling a controller from javascript? - El Forum - 11-19-2008 [eluser]Alexander Obenauer[/eluser] I am trying to submit a form via ajax using prototype )the ajax libraries were just too much for so little). Right now I've got this: Code: var url = '/CIDIRECTORY/CONTROLLERNAME/saveOrder/'; But it doesn't seem to be calling the function in the controller. How do I get it to do that? Calling a controller from javascript? - El Forum - 11-19-2008 [eluser]Randy Casburn[/eluser] You haven't disclosed how you are actually executing this JS. It is constructed properly...but how does it get implemented, started up, called? I can't tell by looking at this snippet. Put it inside a function call if it isn't already...might see improvement. Calling a controller from javascript? - El Forum - 11-19-2008 [eluser]AndrewMalachel[/eluser] I've been in such situation before... ![]() and I found that I ran into some trouble in loading the prototype function... but here's how I describe and solved it... first.. loading the prototype.js file... when using html script tag to load the prototype.js file, I found problem to locate the source file... so I just put them in the ci_directory/js_library/ and then call it in the view file with the html script tag : Code: <script src="<?=base_url()?>js_library/your_jsfile.js" type="text/javascript"> http://your_server/ci_directory/js_library/your_jsfile.js second.. calling the Ajax.Request... (or in my case I use the Ajax.Updater...) to call other controller, I use these codes in the view file... Code: <... onclick="new Ajax.Updater('yourdiv_id','<?=base_url()?>index.php/controller/etc')"> http://your_server/ci_directory/index.php/controller/etc I think it'll works the same in your Ajax.Request function... well it works on my page, I hope it works on yours too... feel free to ask... and if anybody had some other ideas, please share it, since I'm still a newbie also... :-P PS: sorry if my english is poor... :-S I'm still having troubles translating my thought to english! Calling a controller from javascript? - El Forum - 11-20-2008 [eluser]Alexander Obenauer[/eluser] AndrewM - that's perfect! Thanks!! I didn't include the index.php in the url which did the trick. Thanks much. I crapped out and just used an iframe, but now I took it out. Also, you're english is fine! I couldn't tell you weren't a native speaker until you said so. Calling a controller from javascript? - El Forum - 11-20-2008 [eluser]AndrewMalachel[/eluser] [quote author="Alexander Obenauer" date="1227197121"]AndrewM - that's perfect! Thanks!! I didn't include the index.php in the url which did the trick. Thanks much.[/quote] Don't mention it... I often forgot about it also... (~.~!) Glad to help... [quote author="Alexander Obenauer" date="1227197121"].... Also, you're english is fine! I couldn't tell you weren't a native speaker until you said so.[/quote] Ugh.. Thx.. that's too much!! :lol: |