Home Ask Login Register

Developers Planet

Your answer is one click away!

user3551487 February 2016

AJAX with Codeigniter load view automatically

I am looking for help with AJAX and CodeIgniter. I am trying to load a view automatically as the page loads but it doesn't work as expected.

Here is the AJAX code in the view:

$(document).ready ( function(){
    var datas = "badili";
        url: "<?php echo base_url('wapi/featured'); ?>",
        type: 'POST',
        data: { view: datas },
        success: function(response) {

Then in the controller I have created a function that loads the page and feeds it into the div of the view:

public function featured() {
    $dat = $this->input->post('view');
    if ($dat != "") {


Punit kumar Tripathi February 2016

You need to echo view data from action "featured". Use following code in action.

public function featured() {
$dat = $this->input->post('view');
if ($dat != "") {
    echo $this->load->view('featured_wapi', true);

Post Status

Asked in February 2016
Viewed 3,450 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life