在jQuery的阿贾克斯成功的回调,将textStatus永远不会与QUOT;成功"?永远不会、回调、阿贾克斯、jQuery

2023-09-10 16:37:54 作者:想念是会呼吸的痛

在文档有可能值的列表textStatus可能是,如果错误()回调火灾的成功指定(超时,错误,notmodified和parsererror),但没有()完整的()事件。

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() or complete() events.

是否有除了成功的任何其他值可能被传递到成功()回调?这是记录任何地方?

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

推荐答案

成功完整都记录在< A HREF =htt​​p://api.jquery.com/jQuery.ajax/相对=nofollow>此处。你并不真正需要担心什么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.

所以,从一些例子我的工作,我当你点击页面的一节中触发三个功能链接在一起:一个div淡出,而当这样做了它运行Ajax调用。成功函数更新div的内容(而它的淡出),然后将完整的函数调用淡入的股利。那么,它是它淡出,更新和消失回到了新的内容。

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.