Calling a controller from javascript? |
[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?
[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.
[eluser]AndrewMalachel[/eluser]
I've been in such situation before... hut: 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_libra..._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.ph...roller/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!
[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.
[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: |
Welcome Guest, Not a member yet? Register Sign In |