weixin_33713707 2016-05-27 13:14 采纳率: 0%
浏览 67

jQuery失败不触发

I am quite new to jquery/ajax, but I am trying to use done instead of success and fail instead of error. It does what I want for done, but fail does not seem to be firing? The code below works, but if I change error to fail it does not set value of callback to Error.

done: function() {
    callback("Success");
},
error: function() {
    callback("Error");
}

Anyone know what might be wrong?

Thanks!

  • 写回答

1条回答 默认 最新

  • weixin_33716154 2016-05-27 13:17
    关注

    Fail is part of the Promise interface so you need to do it like this

    $.ajax({})
       .done( function() {} )
       .fail( function() {} )
       .always( function() {} );
    
    评论

报告相同问题?