如何在codeigniter中使用ajax加载另一个视图

here is my first view

<form id="bussearch">
<input class="form-control"  id="value1" name="start" type="text" />
<input class="form-control" id="value2" name="value2" type="text" />
<input class="form-control" id="value2" name="value3" type="text" />
<button class="btn" type="submit">Search for Bus</button>
</form>

here is the script

$("#bussearch").submit(function(e) {
   $.ajax({
       type: "POST",
       url: "http://siteurl/controller/test",
       data: $("#bussearch").serialize(), 
       success: function(data)
       {
                     $("#div_result").html(data);
           //alert(data); 
       }
     });

e.preventDefault(); // avoid to execute the actual submit of the form.
});

Here is my controller

function test()
{

      $response = $this->load->view('welcome_message',TRUE);
    echo $response;

    }

here is the view welcome_message

 <div id="div_result"></div>

I need to load a view after ajax sucess function, but view welcome_message is not loading

I do something similar to this to load data into modals.

In my controller I just call for the view:

public function update_user_modal()
{
    $this->load->view('modals/update_user_modal');
}

The ajax is like this:

$.ajax({
    url: "<?php echo base_url('admin/get_user_details'); ?>",
    type: "POST",
    data: { id: id }
  }).done(function(msg) {
   console.log(msg);  // this will have the content of the view
  }.fail(function(jqXHR, textStatus) {
    alert("Request failed: " + textStatus + " - Please try again.")
  })

I presume it is a typo in the ajax url you have provided as you are calling function test() within the controller but you are providing the function bus_test() in your controller.

Hope this helps.