2017-03-17 14 views
1

私のリストをデータベースに更新すると、正常に実行されているAjaxリクエストも戻ってきますが、私のリストは更新されていません。Ajaxレスポンスが特定のList codeigniterを更新していませんか?

View.php:

  <li class="fileLiContent" id="fileLi<?php echo $row['lpf_id'];?>" data-fileid="<?php echo $row['lpf_id'];?>"> 
       <div class="checkbox edit<?php echo $row['lpf_id'];?>"> 
        <label class="no-padd"> 
         <input type="checkbox" class="checkboxClass" value=""> 
         <span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span> 
         <span class="title"><?php echo $row['lpf_name'];?> <a href="#" class="gap-ml-25" onclick="editId(<?php echo $row['lpf_id']; ?>);">edit</a></span> 
        </label> 
       </div> 

       <div class="editText<?php echo $row['lpf_id'];?>" style="display: none;"> 
        <input type="text" name="file_name" class="my-app-input in-default textbox<?php echo $row['lpf_id'];?>" placeholder="Type file name" value="<?php echo $row['lpf_name'];?>"> 
        <a href="#" class="btn my-btn btn-blue" style="margin-right: 5px;" onclick="updateId(<?php echo $row['lpf_id']; ?>);">Update</a> 
        <a href="#" class="btn my-btn btn-blue" style="margin-right: 5px;" onclick="cancelId(<?php echo $row['lpf_id']; ?>);">Cancel</a> 
        <?php $this->load->view('petition/dateMultipleUpload',$row); ?> 
       </div> 

       <span class="details ml"><?php echo date("m/d/Y", strtotime($row['lpf_created_date']));?></span> 
       <br> 

       <span class="details ml"><?php echo basename($row['lpf_path']) ;?></span> 

       <br> 

       <?php if($row['lpf_expiry_date'] != '0000-00-00 00:00:00') :?> 
        <span class="details ml" style="font-weight: bold;">Expiry date:&nbsp;&nbsp;</span><?php echo date("m/d/Y", strtotime($row['lpf_expiry_date']));?> 
        <br> 
       <?php endif ;?> 

       <?php if($row['lpf_due_date'] != '0000-00-00 00:00:00') :?> 
        <span class="details ml" style="font-weight: bold;">Due date:&nbsp;&nbsp;</span><?php echo date("m/d/Y", strtotime($row['lpf_due_date']));?> 
        <br> 
       <?php endif ;?> 

       <?php if($row['lpf_approval_date'] != '0000-00-00 00:00:00') :?> 
        <span class="details ml" style="font-weight: bold;">Approval date:&nbsp;&nbsp;</span><?php echo date("m/d/Y", strtotime($row['lpf_approval_date']));?> 
        <br> 
       <?php endif ;?> 

       <?php if($row['lpf_remainder_date'] != '0000-00-00 00:00:00') :?> 
        <span class="details ml" style="font-weight: bold;">Reminder date:&nbsp;&nbsp;</span><?php echo date("m/d/Y", strtotime($row['lpf_remainder_date']));?> 
        <br> 
       <?php endif ;?> 

       <?php if($row['lpf_note'] != "") :?> 
        <span class="details ml" style="font-weight: bold;">Notes:&nbsp;&nbsp;</span><?php echo $row['lpf_note'];?> 
        <br> 
       <?php endif ;?> 

Model.php

public function getPetionFile() 
{ 
    $query = $this->db->query("SELECT * FROM lpd_petition_files WHERE lpf_id = 147 "); 
    return $query->row(); 
} 

Controller.php私は特定のリストの詳細を取得します

public function performUpdateDocumentName(){ 
    $data = $this->petition_model->getPetionFile(); 
    echo json_encode($data);} 

アヤックス:特定のリスト

を更新しよう
function updateId(id) { 

var filename =$('.textbox'+id).val(); 
var expirydate = $('.expiryDateHV'+id).val(); 
var duedate = $('.dueDateHV'+id).val(); 
var reminder = $('.reminderHV'+id).val(); 
var note = $('.noteValue'+id).val(); 

$.ajax({ 
    url: "<?php echo base_url('Petition_controller/performUpdateDocumentName/'); ?>"+id, 
    type: 'POST', 
    dataType : 'json', 
    data: { 'filename': filename, 'expirydate' : expirydate, 'duedate' : duedate, 'reminder' : reminder, 'note' : note }, 
    error: function(reponse) { 
      }, 
    success: function(reponse){ 

     $(".editText"+id).hide(); 
     $('.edit'+id).show(); 

     $('#fileLi'+id).html(reponse); 
    } 
}); } 
+0

= 147が静的に与えられている...それは大丈夫ですか動的にする必要がありますか? –

+0

完璧に動作していますが、応答はUI – smviswa

+0

に更新されていません。あなたはajaxリクエストで '' async:false'''を試しましたか? – kishor10d

答えて

0

Controller.php

 $update = $this->model->updateFiles($uploadData); 

    $statusMsg = $update?'success':'error'; 

    if ($statusMsg == 'success') { 
    $data['row'] = $this->petition_model->getPetionFile($id); 
    $theHTMLResponse = $this->load->view('UploadedFilesList.php', $data, true); 

    echo json_encode(array('success'=>'success', 'dataa'=> $theHTMLResponse)); 
    }else{ 
    echo json_encode(array('error'=>'Something went wrong, please try again.')); 
    } 

アヤックス:あなたのモデルクエリーlpf_idで

function updateId(id) { 

var filename =$('.textbox'+id).val(); 
var expirydate = $('.expiryDateHV'+id).val(); 
var duedate = $('.dueDateHV'+id).val(); 
var reminder = $('.reminderHV'+id).val(); 
var note = $('.noteValue'+id).val(); 

$.ajax({ 
    url: "<?php echo base_url('petitions/perform/updateDocumentName/'); ?>"+id, 
    type: 'POST', 
    dataType : 'json', 
    data: { 'filename': filename, 'expirydate' : expirydate, 'duedate' : duedate, 'reminder' : reminder, 'note' : note }, 
    error: function(response) { 
     alert('Something went wrong, please try again.'); 
      }, 
    success: function(response){ 

     if(response.success == 'success'){ 
      alert('File updated successfully.'); 
      $('#filesList #updateUI'+id).html(response.dataa); 

     }else{ 
      alert('Something went wrong, please try again.'); 
     } 
     $(".editText"+id).hide(); 
     $('.edit'+id).show(); 

    } 
}); } 
関連する問題