在函数成功执行并发送到数据库后,我无法获得"Thank you for your enquiry!"
的警报。我的代码如下:
function addenquiry() {
Texttitle = $("#Texttitle").val();
Textenquiry = $("#Textenquiry").val();
if (validate()) {
var xmlhttp = new XMLHttpRequest();
var url = serverURL() + "/addenquiry.php";
url += "?userid=" + userid + "&Texttitle=" + Texttitle + "&Textenquiry=" + Textenquiry;
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
addEnquiry(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
}
function addEnquiry(response) {
var arr = JSON.parse(response);
if (arr[0].result == 1) {
alert("Thank You for your enquiry!")
}
else {
alert("Sorry please try again");
}
}
不确定我哪里出错了,标题和消息已成功记录在数据库中,但我没有收到警报,希望得到某人的指导和帮助。谢谢!