单击按钮将状态更新为通过AJAX批准

时间:2019-03-06 15:29:07

标签: php jquery ajax

当我单击按钮时,如何更新已批准的“状态”字段?

function UpdateRecord(id) {
  jQuery.ajax({
    type: "POST",
    url: "update.php",
    data: 'id=' + id,
    cache: false,
    success: function(response) {
      alert("Record successfully updated");
    }
  });
}

1 个答案:

答案 0 :(得分:0)

 <script>
  function UpdateRecord(id)
  {
   jQuery.ajax({
     type: "POST",
     url: "update.php",
     data: {id:id},
     cache: false,
     success: function(response)
     {
       alert("Record successfully updated");
     }
 });
   }
 </script>

和update.php

<?php 
   if(isset($_POST['id']))
   { 
    $id = $_POST['id'];
   // update here to this id..
   }
   ?>