[英]AJAX not updating MySql data
I have created this PHP script to update the status of users.我创建了这个 PHP 脚本来更新用户的状态。 I am having some difficulty while running the below code.
运行以下代码时遇到一些困难。 The code of the page is given below: -
该页面的代码如下:-
$query = "DELETE FROM users WHERE id='$id' ";
$query_run = mysqli_query($conn, $query);
if($query_run)
{
$_SESSION['status'] = "Successfully Deleted";
header('Location: index.php');
}
else
{
$_SESSION['status'] = "Something Went Wrong.!";
header('Location: index.php');
}
The query here fails to run.此处的查询无法运行。 The below ajax code sends the data to this page using a POST request
以下 ajax 代码使用 POST 请求将数据发送到此页面
$.ajax({
type: "POST",
url: "code.php",
data: {
'checking_edit_btn': true,
'student_id': stud_id,
},
success: function (response) {
$.each(response, function (key, value) {
$('#edit_id').val(value['id']);
});
$('#editStudentModal').modal('show');
};
});
update It's working now, here is the final code:更新它现在正在工作,这是最终代码:
$.ajax({
type: "POST",
url: "code.php",
data: {
'delete_student': true,
'student_id': stud_id,
},
success: function (response) {
$.each(response, function (key, value) {
$('#edit_id').val(value['id']);
});
$('#editStudentModal').modal('show');
};
});
where you sending 'update_student'/'delete_student'?你在哪里发送'update_student'/'delete_student'?
try to add to data尝试添加到数据
update_student: true
or要么
delete_student: true
depends on button取决于按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.