Accesing jQuery from Controller |
[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
[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.
[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?.
[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
[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..
[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!
|
Welcome Guest, Not a member yet? Register Sign In |