问题描述
在$ .post的成功,有成功的处理程序。如果失败了怎么办?是否有一个类似的处理程序,我们可以利用这种情况,以便我们能够告知自己是不是发生了吗?用户
When $.post succeeds, there is a success handler for it. What happens if it fails? Is there a similar handler that we can use for this case, so that we can inform the user that something is not happening right?
推荐答案
还有,是不是按照文档,对于 $。后一个特定的错误处理程序
方法。
There is not, according to the documentation, a specific error handler for $.post
method.
您需要做什么,如果你想同时拥有成功和失败的处理程序,是使用低级别的 $。阿贾克斯
方法。它的文档可以在这里找到: http://api.jquery.com/jQuery.ajax/
What you have to do, if you want to have both the success and fail handlers, is to use the low-level $.ajax
method. It's documentation can be found here: http://api.jquery.com/jQuery.ajax/
$.ajax({
type: "POST",
url: "some.php",
success: function(html){
/* Do success stuff here */
},
error: function(){
/* do error stuff here */
}
});
这篇关于jQuery的:有jQuery中故障处理程序$。员额?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!