我有一个邮政电话。在结果之后我想再做一次CALL检查状态。但只有如果状态已完成。如何在jquery中进行轮询?
jQuery.ajax({
type: "POST",
contentType: "application/json",
url: "/doPostURL....,
headers: {
"x-csrf-token": sCsrftoken
},
success: function() {
.. now I want to do the polling on the status
jQuery.ajax({
type: "GET",
dataType: "json",
url: "/getStatusUrl ,
success: function(data, textStatus, response) {
// to continue only if status if Finished
},
error: function() {
}
});
}
});
为什么你不能在成功函数上打电话? –
第一个电话是POST,然后我需要打电话查看统计信息。如果状态为“已完成”,我想继续但可能需要时间 – user1365697
“contentType:”application/json“,” - 您正在发出GET请求。没有请求主体来描述内容类型。那里在做什么?你用'dataType'混淆了它吗? (对于这个问题,前面的POST请求没有'data',所以它里面也没有任何JSON) – Quentin