In jQuery's ajax success callback, will textStatus ever not be “success”?

前端 未结 4 1047
轻奢々
轻奢々 2020-12-31 00:38

In the documentation there is a list of possible values that textStatus might be if the error() callback fires (\"timeout\", \"error\", \"notmodified\" and \"pa

4条回答
  •  青春惊慌失措
    2020-12-31 01:09

    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.

    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.

提交回复
热议问题