在codeigniter中使用ajax加载模式对话框

I'm using codeigniter php (MVC framework) and I want to open a modal dialog when clicked a button, but my problem is that my modal appears only in my response network(in preview) and not on my actual screen.

This is my modal.php file on view side.

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

This is my controller to point to that view:

 public function showmachinelist() {
        $this->load->view('monitor/modal');

    }

And I have this button in js to trigger my ajax:

button_2: "<button type=\"button\" class=\"getid btn btn-default tara\" data-target=\"#myModal\" data-toggle=\"modal\" data-id=\""+ missedEntry.id +"\" >Select</button>"

And this ajax:

$.ajax({
    type: "POST",
    url: "Monitor/showmachinelist",
    data: {'val' : imagename},
    dataType: "text"
    }).done(function(data) {
   console.log("test2");
   }).fail(function() {
alert( "error" );
});

How I can make show that modal?

</div>

Your ajax returns you some html, you have to put that html into a div and make that div a popup or modal or dialog. For this you can use Bootstrap Modal, Jquery UI Dialog etc.

Bootstrap Modal

Jquery UI Dialog