【发布时间】:2018-04-21 23:11:57
【问题描述】:
当我尝试发帖时,数据被发送并且服务器接收它但从未调用成功函数。连接在 chrome 的网络检查器选项卡中显示为已停止,并显示警告:连接尚未完成。
脚本:
var modif = {
CRN: $("#DIAS").parent().parent().parent().children()[0].children[0].innerText,
DIAS: $("#DIAS").val(),
start_hr: $("#STRHR").val(),
end_hr: $("#ENDHR").val(),
title: $("#TITLE").val()
}
$.ajax({
url: '/cmanager/edit',
dataType: 'text',
type: 'POST',
data: modif,
success: function (order) {
alert("functiono!");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("Error, status = " + textStatus + ", " +
"error thrown: " + errorThrown
);
服务器:
app.post("/cmanager/edit",function (req, res) {
var CRN = req.body.CRN;
var DIAS = req.body.DIAS;
var start_hr = req.body.start_hr;
var end_hr = req.body.end_hr;
var title = req.body.title;
console.log(CRN);
console.log(DIAS);
console.log(start_hr);
console.log(end_hr);
console.log(title);
var usrq = "update section natural join class set DIAS = '"+DIAS+"', start_hr = '"+start_hr+"', end_hr = '"+end_hr+"', title = '"+title+"' where CRN = '"+CRN+"';";
connection.query(usrq, function (error, results, fields) {
if (error)
console.log(error.code);
else
try {
console.log("hello");
} catch (error) {
console.log("bad ifo by client");
}
});
})
【问题讨论】:
-
你有一个错字。应该是
success而不是succes。 -
@Li357 这是一件小事,但将其作为答案发布,以便问题可以结束。
-
谢谢,抱歉。还是不行。
标签: javascript jquery ajax express post