我有一个基于结果的AJAX调用 - 我发送另一个电话。
uploadDocument = function (doc1, doc2) {
$.ajax({
type: "POST",
url: "/API/UploadDocs/addDocument",
data: doc1,
contentType: "application/json"
}).then(function (result) {
console.log(result);
doc2.id=result;
return $.ajax({
type: "POST",
url: "/API/UploadDocs/addDocument",
data: doc2,
contentType: "application/json"
}).then(function (result) {
});
});
}
但是我收到Illegal invocation
错误,我做错了什么?
答案 0 :(得分:1)
当通过AJAX传递的数据出现错误时,会出现非法调用错误
检查doc1和doc2的类型。也尝试将 def keypress(self, event):
print(time.time(), "KEYPRESS {char!r} keysym='{keysym}' keycode={keycode} keysym_num={keysym_num} state={state}".format(**vars(event)))
def keyrelease(self, event):
print(time.time(), "KEYPRESS {char!r} keysym='{keysym}' keycode={keycode} keysym_num={keysym_num} state={state}".format(**vars(event)))
传递给ajax。
答案 1 :(得分:1)
你正在承诺错误的链接!当您返回承诺时,您必须继续调用您正在解决的承诺的then
。
阅读链接部分:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then
uploadDocument = function (doc1, doc2) {
$.ajax({
type: "POST",
url: "/API/UploadDocs/addDocument",
data: doc1,
contentType: "application/json"
}).then(function (result) {
console.log(result);
doc2.id=result;
return $.ajax({
type: "POST",
url: "/API/UploadDocs/addDocument",
data: doc2,
contentType: "application/json"
});
}).then(function (result) {
//Continue here
});
}