CodeIgniter Forums

Full Version: How to open a pdf file in modal window dynamically?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want top open a pdf file in modal window dynamically? how to open. 
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal1" onclick="edit_book_kvr(<?php echo $row['markid'];?>)" >Open Modal</button>
 function edit_book_kvr(markid)
     save_method = 'update';
     $('#form1')[0].reset(); // reset form on modals

     //Ajax Load data from ajax
       url : "<?php echo site_url('/users/ajax_edit_kvr')?>/" + markid,
       type: "POST",
       dataType: "JSON",
       success: function(data)

           $('.modal-title').text('Upload Images');

       error: function (jqXHR, textStatus, errorThrown)
           alert('Error get data from ajax');
public function ajax_edit_kvr($markid)
//$data = $this->User_model->get_by_id($markid);
$data['files'] = $this->User_Model->getRows($markid);

echo json_encode($data);

<?php if(!empty($files)){ foreach($files as $frow)
                   <div class="modal-body">
                      <embed src = "<?php echo base_url().'uploads/files/'.$frow[0] ['file_name']; ?>" name ="markid1" type='application/pdf' frameborder="0" width="100%" height="400px">

                       <!--  <embed src="/uploads/files/sa87356245767aa912a72e93b23735d1f.pdf" type="application/pdf" width="100%" height="100%"> -->


<?php } } ?>  
For static image for one image is working. but the pdf should be dynamically.