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

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

问题描述

文档 中有一个可能的值列表,如果 error() 回调触发(超时"、错误"、未修改"和解析器错误"),但没有为 success() 事件指定任何内容.

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() 回调吗?这在任何地方都有记录吗?

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

推荐答案

Successcomplete 记录在 这里.你真的不需要担心什么 textStatus 传递给函数,它都是自动处理的.当/如果调用成功,则调用 success 函数,并在其他所有事情的最后调用 complete.

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.

所以,作为我正在做的事情的一个例子,我将当你点击页面的一部分时触发的三个函数链接在一起:一个 div 淡出,当它完成时它运行一个 ajax 调用.success 函数更新 div 的内容(当它淡出时),然后 complete 函数调用 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天全站免登陆