php - 单击按钮时通过 AJAX 将状态更新为已批准
问题描述
单击按钮时,如何将“状态”字段更新为已批准?
function UpdateRecord(id) {
jQuery.ajax({
type: "POST",
url: "update.php",
data: 'id=' + id,
cache: false,
success: function(response) {
alert("Record successfully updated");
}
});
}
解决方案
<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..
}
?>
推荐阅读
- angular - 如何在我的 sidenav 之外显示我的模态?我正在使用:主机。角
- crud - 如何在自定义管理 CRUD 控制器中实现具有两个关联字段的依赖选择(EasyAdminBundle 3、Symfony 5)
- ms-access - 如何从两个表中有共同值的 1 个表中查询值
- javascript - javascript脚本在电子中不起作用
- json - 在 AlamoFire 完成操作后,努力让函数触发
- logging - 来自工作日志的 Gitlab 自定义徽章
- css - 闪亮的`sliderInput()`的内联标签
- azure - 用于 SAS 和 CDN 身份验证令牌的 URL 重写的 Azure CDN
- javascript - 如何从 Vuejs 的下拉列表中显示选定的值?
- html - 将 CSS 选择器与 ::after 选择器结合使用