我有一个表单,我提交到一个 php 文件,该 php 文件将检查该记录是否存在。如果存在,它将回显“已存在”。在我的ajax“成功”中,它确实看到“已经存在”,但是当我设置条件时它不起作用。例如,在我的 ajax 函数成功下,我放置了以下内容
$.ajax({
type: "GET",
data: $('#minifrm').serialize(),
url: "CRUD/myfile.php?check=" + para + "&freq=" + freq + "&expire=" + expire,
success: function (status) {
if (status.success == false) {
alert("Your details we not saved");
} else {
var checkstatus = status.toString();
if (checkstatus === 'Already Exists')
{
alert("You are here");
}
if (checkstatus === '')
{
alert("There is nothing");
}
}
}
});
目前它会回显“已存在”并提醒“您在这里”,但如果不存在,则不会提醒“没有任何内容”。
最佳答案
使用 double 等于 ==
而不是单个 =
来比较两个变量,如下所示:
if(checkstatus == 'Already Exists')
{
alert("You are here");
}
关于javascript - jQuery Ajax 成功提交条件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37025266/