当服务器返回429“请求过多”状态时,将弹出警报,但页面将更改为/ ProjectCanvas。永远不会打印“确定”。
$.post("/createProject/", null, ).fail(function() {
alert("You are doing that too much. Please wait before trying again.");
}).done(function(data, status) {
console.log("OK")
window.location.href = "/ProjectCanvas/";
})
我认为浏览器错误地预测了成功的响应,并在意识到不应执行之前开始执行它。
到目前为止,这种情况发生在Chrome和Edge上,野生动物园工作正常。有人知道这里的问题吗?
答案 0 :(得分:-1)
jQuery post方法中的参数是回调函数。
$.post("/createProject/", function() {
var defer = $.Deferred();
if(status === "success"){
defer.promise(data);
}
})
.done(function(data) {
console.log("OK")
window.location.href = "/ProjectCanvas/";
})
.fail(function() {
alert("You are doing that too much. Please wait before trying again.");
})