首页 > 解决方案 > 单击按钮时通过 AJAX 将状态更新为已批准

问题描述

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

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

标签: phpjqueryajax

解决方案


 <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..
   }
   ?>

推荐阅读