Problem updating a div with ajax (json_encode) - 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: Problem updating a div with ajax (json_encode) (/showthread.php?tid=55545) |
Problem updating a div with ajax (json_encode) - El Forum - 10-31-2012 [eluser]Unknown[/eluser] Hello everyone Im stuck for 2 days now , and i need your help. I want to use ajax to update a div with the class .user-responce,every time the database column "status" is updated. I have a problem though, manipulating the json object created by the ajax controller and return it back at the view from jquery. This $data variable into controller makes my life hard at the moment and i keep getting errors. I please for your help and thanks in advance) Here is my index controller Code: <?php This is my Ajax_controller.php Code: <?php My Model home_page_model.php Code: <?php And finally my View Code: <!DOCTYPE html> Problem updating a div with ajax (json_encode) - El Forum - 11-01-2012 [eluser]LuckyFella73[/eluser] Your Ajax controller has to return the result as json. You can't just load a view in your controller to get a json result. Your controller function should more look like: Code: public function GetOnlineUsers() If you want to format (HTML) the result before the data is send to the js function you can do that too. EDIT: I looked at your controller code and saw your json_encode function so I thought you expect a json as the result for your js function. But now I see you use the jquery "load" function. So my code might not help you. Can you post what kind of errors do you get? |