![]() |
Accesing jQuery from Controller - 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: Accesing jQuery from Controller (/showthread.php?tid=21420) |
Accesing jQuery from Controller - El Forum - 08-09-2009 [eluser]riko0na[/eluser] I am using ajax to view the display made from the controller by getting data from the database like this also I use jQuery for the Date(I've showed only this part) VIEW: Code: <head> CONTROLLER: Code: function edcategory($cname) my question is, can I call the jQuery function from the controller with this code? newbie here. . cause it works fine when i call the jQuery function from the view page..also the call from the ajax to controller works fine also,, confuse here :-S Accesing jQuery from Controller - El Forum - 08-10-2009 [eluser]Phil Sturgeon[/eluser] You cannot call jQuery functions (or any JavaScript) from a server-side language like PHP. PHP (and therefore CodeIgniter) does all its work on the server, JavaScript does all its work on the client-side (the users browser) so the interaction between the two goes like this: 1.) CodeIgniter (PHP) works out which controller and which method to use, which then picks a view file. 2.) A view file includes all sorts of HTML, images, CSS, JavaScript, Flash, etc. 3.) jQuery (JavaScript) can then call another CodeIgniter page via AJAX to get a response in a similar way. And repeat. Accesing jQuery from Controller - El Forum - 08-10-2009 [eluser]riko0na[/eluser] 3.) jQuery (JavaScript) can then call another CodeIgniter page via AJAX to get a response in a similar way. but what if the codeigniter page response via AJAX contains a jQuery function.. would that be possible.. what will i do?. Accesing jQuery from Controller - El Forum - 08-10-2009 [eluser]jcavard[/eluser] [quote author="riko0na" date="1249974486"]but what if the codeigniter page response via AJAX contains a jQuery function.. would that be possible.. what will i do?.[/quote] Evaluate the response accordingly and it will work. Have a look here, MALSUP has a neat library which allow you to handle any response. You can have javascript no problem! Good luck Accesing jQuery from Controller - El Forum - 08-12-2009 [eluser]riko0na[/eluser] Phil Sturgeon and jcavard, thank you for your replies.. I've finally got my problem answered just call the jquery again if the codeigniter page response via AJAX contains a jQuery call function.. Accesing jQuery from Controller - El Forum - 08-12-2009 [eluser]Johan André[/eluser] [quote author="jcavard" date="1249976355"] Have a look here, MALSUP has a neat library which allow you to handle any response. You can have javascript no problem! Good luck[/quote] The taconite stuff looks awesome! I've missed that one... Bookmarked! Accesing jQuery from Controller - El Forum - 08-12-2009 [eluser]Phil Sturgeon[/eluser] Yeah that really is awesome. Good spot! |