在jQuery的ajax成功回调中,textStatus不会是“成功”? [英] In jQuery's ajax success callback, will textStatus ever not be "success"?

查看:249
本文介绍了在jQuery的ajax成功回调中,textStatus不会是“成功”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档中,有一列textStatus可能的值,如果 error() callback fires(timeout,error,notmodified和parsererror / code>事件。

In the documentation there is a list of possible values that textStatus might be if the error() callback fires ("timeout", "error", "notmodified" and "parsererror") but nothing specified for the success() event.

除了success之外,还有其他值可以传递给 success c $ c> callback?

Are there any other values besides "success" that could be passed to the success() callback? Is this documented anywhere?

推荐答案

成功 complete 已记录在此处。你真的不需要担心什么textStatus传递给函数,它都会自动处理。当/调用成功时调用成功函数,并且在其他任何结束时调用完成。

Success and complete are documented at here. You don't really need to worry about what textStatus is passed to the functions, it's all handled automatically. The success function is called when/if the call succeeds, and complete is called at the very end of everything else.

所以,作为一个例子, on,我链接了三个函数,当您单击页面的一部分时触发:一个div淡出,当完成它运行一个ajax调用。成功函数更新div的内容(当它淡出),然后完整的函数在div上调用fadeIn。所以它做的是它淡出,更新,并与新的内容回退。

So, as an example from something I'm working on, I chained together three functions that are triggered when you click a section of the page: a div fades out, and when that's done it runs an ajax call. The success function updates the content of the div (while it's faded out), and then the complete function calls fadeIn on the div. So what it does is it fades out, updates, and fades back in with new content.

这篇关于在jQuery的ajax成功回调中,textStatus不会是“成功”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆