Welcome Guest, Not a member yet? Register   Sign In
ajax value not returned
#1

Code:
<td class="text-center">
<button class="btn btn-sm btn-danger deleteUser" data-toggle="modal"
data-target="#myModal1" onclick="edit_book1(<?php echo $row['markid'];?>)">
<i class="fa fa-upload"></i></button>
</td>
Code:
function edit_book1(markid)
   {
     save_method = 'update';
     $('#form1')[0].reset(); // reset form on modals

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

//window.alert($('[name=title]').val(data.markid));
           $('[name="markid1"]').val(data.file_name);
          // $('[name="appno"]').val(data.appno);
         
           
           $('#modal_form1').modal('show'); // show bootstrap modal when complete loaded
           $('.modal-title').text('Upload Images'); // Set title to Bootstrap modal title

       },
       error: function (jqXHR, textStatus, errorThrown)
       {
           alert('Error get data from ajax');
       }
   });
   }
Code:
Controller
**********
public function ajax_edit1($markid)
   {    

$data = $this->User_Model->getRows($markid);
echo json_encode($data);

   }



Code:
Model
*****
   function getRows($markid = array()){
       $this->db->select('*');
       $this->db->from('upload_ins');
       $this->db->where('certid',$markid);
     
           $query = $this->db->get();
           return $query->row();  
       
   }
Code:
Model window
************

<?php if(!empty($files)){ foreach($files as $frow)
                     {
print_r($frow);
                      ?>
<embed src = "<?php echo base_url().'uploads/files/'.$frow ['file_name']; ?>" type='application/pdf' frameborder="0" width="100%" height="400px">
Reply
#2

How many time must I tell you that the site_url() adds the / slash to the end of it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB