![]() |
Ajax Toggle Button - 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: Ajax Toggle Button (/showthread.php?tid=23811) |
Ajax Toggle Button - El Forum - 10-22-2009 [eluser]bennyhill[/eluser] I have a data table of event attendees. I would like to place a graphical toggle button next to each name that says either "yes" or "no". When the button is pressed I want to make an ajax call to update a database record. Anyone know how to do this? I am mainly confused on the AJAX (javascript) calling a controller function part. I am willing to use JQuery. Thanks Ajax Toggle Button - El Forum - 10-22-2009 [eluser]markup2go[/eluser] It's very easy to handle ajax with jQuery: Code: $.ajax({ Ajax Toggle Button - El Forum - 10-22-2009 [eluser]bennyhill[/eluser] How would I call this from a click event and pass an argument to it? Ajax Toggle Button - El Forum - 10-22-2009 [eluser]mattpointblank[/eluser] It might be worth you reading up on basic javascript rather than copy/pasting posts from here. Code: function doSomething(argument) Ajax Toggle Button - El Forum - 10-22-2009 [eluser]bennyhill[/eluser] Yeah prolly. Thanks. Think you forgot the click handler in the anchor. Ajax Toggle Button - El Forum - 10-22-2009 [eluser]mattpointblank[/eluser] Ah, I put it in but it looks like it got stripped from the forum code. Should be easy enough to add, and for bonus points you can use jQuery's bind() function to add it on load, removing the need for onclick in the html. |