Load View into JSON object - 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: Load View into JSON object (/showthread.php?tid=24443) |
Load View into JSON object - El Forum - 11-10-2009 [eluser]alboyd[/eluser] **DELETE PLEASE** - I am an idiot! OMG This *must* be a stupid question - I think perhaps I am misunderstanding the purpose of JSON. So quick background - I have a fairly complex CodeIgniter site which uses masses of JQuery AJAX calls. Currently I think my implementation of this is dodgy and so I am trying to improve. Currently I will do something like this: Code: .. This works fine. However I'll evaluate if there is an error by doing something like this: Code: if (data == 'Error') { do blah } Or maybe I want to redirect for some errors or print an error message for others and it's just ugly. So I thought I would spend some time and re-write everything using JSON returned results. But, in the example above - i'm unable to get the page content "data" returned as something like "data.content". In my controller function I have tried this: Code: $content = $this->load->view('main_admin/forms/view_update_user_details_form', $this->view_data, TRUE); But when loaded: Code: $.post(base_url + "main_admin/update_user_details", { user_id_str : user_id_str }, All the dynamic elements of the view which use the contents of $this->view_data are empty. Is it not possible or not intended to put a whole output of a view into a element of a JSON object? |