javascript - AJAX with Codeigniter load view automatically -
i looking ajax , codeigniter. trying load view automatically page loads doesn't work expected.
here ajax code in view:
$(document).ready ( function(){ var datas = "badili"; $.ajax({ url: "<?php echo base_url('wapi/featured'); ?>", type: 'post', data: { view: datas }, success: function(response) { $('#thechange').html(response); } }); });
then in controller have created function loads page , feeds div of view:
public function featured() { $dat = $this->input->post('view'); if ($dat != "") { $this->load->view('featured_wapi'); } }
you need echo view data action "featured". use following code in action.
public function featured() { $dat = $this->input->post('view'); if ($dat != "") { echo $this->load->view('featured_wapi', true); }}
Comments
Post a Comment