Update Main Content of Template when using Ajax - 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: Update Main Content of Template when using Ajax (/showthread.php?tid=56526) |
Update Main Content of Template when using Ajax - El Forum - 12-28-2012 [eluser]Unknown[/eluser] I am fairly new to CI and have come across an issue that I just can't seem to resolve or find an answer for. I have an admin page that lists all my FAQ's and on that page I can add, edit and delete FAQs which all works fine using CI and Ajax (in general). The problem I am having is that I want to 'reload' the main content of my CI template after adding an FAQ so that the new FAQ is listed and I just can't get it to work. In my main template I have: Code: <?php $this->load->view('layout/header'); ?> The Ajax Code: $("#add-faq").submit(function(e){ In the controller the main method is Code: function admin_index() Code: function save_faq() Update Main Content of Template when using Ajax - El Forum - 12-28-2012 [eluser]InsiteFX[/eluser] Replace $ in script tag with s Code: <head> Code: $("#add-faq").submit(function(e){ Update Main Content of Template when using Ajax - El Forum - 12-29-2012 [eluser]Unknown[/eluser] I am not entirely sure how your solution of adding my base_url (and I have removed index.php so don't need that) helps with my problem of reloading the main content of my template? Everything works exactly as it should otherwise (i.e. the Ajax processes the PHP and if I just return a string that is fine) so I haven't got a problem with the url in the ajax. Update Main Content of Template when using Ajax - El Forum - 12-30-2012 [eluser]GrahamDj28[/eluser] You must echo your data that you want to return. If you don't do that then it will have no data to add to the content. Try this: Code: if ($this->input->post('ajax')) { By doing this you must decode the json in your ajax success method. |