简体   繁体   English

jQuery .done()不在$ .post上触发

[英]jQuery .done() not firing on $.post

I have the following sentence: 我有以下句子:

var token = 'token';

$.post("/signup.php", {token: token}).done(function(data) {
    alert("done");
});

This actually doesn't works, and I honestly don't know why, because it's so simply... I have jQuery 1.11.1, and "signup.php" takes up to 10 seconds to be completed and return a success answer. 这实际上是行不通的,老实说我也不知道为什么,因为它是如此简单……我有jQuery 1.11.1,“ signup.php”最多需要10秒钟才能完成并返回成功答案。 It's possible it's not working due the time signup.php takes to be processed? 由于signup.php需要处理时间,因此可能无法正常工作?

Thank you guys 感谢大伙们

try adding timeout attribute, since the result is taking too much time. 尝试添加超时属性,因为结果花费了太多时间。 Also, I feel that token should be in headers attribute. 另外,我觉得令牌应该在headers属性中。

$.post("/signup.php", {headers: {token: token}, timeout : 20000}).done(function(data) {
    alert("done");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM