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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -