Welcome Guest, Not a member yet? Register   Sign In
How to open a pdf file in modal window dynamically?
#1

I want top open a pdf file in modal window dynamically? how to open. 
Code:
<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>
Code:
 function edit_book_kvr(markid)
   {
     save_method = 'update';
     $('#form1')[0].reset(); // reset form on modals

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

           $('[name="title"]').val(data);          
           $('#modal_form1').modal('show');
           $('.modal-title').text('Upload Images');

       },
       error: function (jqXHR, textStatus, errorThrown)
       {
           alert('Error get data from ajax');
       }
   });
   }  
Code:
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);

   }
Code:
<?php if(!empty($files)){ foreach($files as $frow)
                     {
print_r($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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB