jquery::ajaxStop() versus jquery::ajaxComplete()
来源:互联网 发布:促进身高的运动 知乎 编辑:程序博客网 时间:2024/05/20 16:10
http://stackoverflow.com/a/4421115/2177408
Well, the short version is they serve different purposes, so the answer would be the "a combination of both for various situations" option. The basic rules are:
.ajaxComplete()
- runs for every request that completes, use this when you want to do something with each request/result. Note that this doesn't replace thesuccess
handler, since the parsed data is not one of the arguments (and it runs even when there's an error) - you may want.ajaxSuccess()
in some per-request situations instead..ajaxStop()
- runs when every batch of requests completes, usually you'd use this in combination with.ajaxStart()
for things like showing/hiding a "Loading..." indicator of some sort - or to do something else once a batch of AJAX requests finishes, like a master last step.
If you're using this to parse your data, there's probably a better way, in this case $.ajaxSetup()
, where you can specify a success
handler that gets the already-parsed data (e.g. JSON responses will be objects), like this:
$.ajaxSetup({ success: function(data) { //do something with data, for JSON it's already an object, etc. }});
0 0
- jquery::ajaxStop() versus jquery::ajaxComplete()
- jQuery ajax请求 - ajaxStart() ajaxSend() ajaxStop() ajaxComplete()方法
- jquery 源码分析9-ajax(E)全局函数ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend
- jQuery API .ajaxComplete()
- jquery ajaxStart() ajaxComplete()
- jQuery API .ajaxStop()
- JQUERY ajaxStart()和ajaxStop()方法
- jquery学习笔记 ajaxStart ajaxStop
- jQuery Ajax事件-ajaxStop(callback)
- jquery ajaxStart, ajaxStop 显示loading
- jQuery(htmlString) versus jQuery(selectorString)
- jQuery Ajax事件—ajaxComplete(callback)
- jQuery ajaxComplete()方法,判断ajax请求状态
- ajaxStart()与ajaxStop() | ajaxSend()与ajaxComplete() | ajaxError()
- Jquery ajaxStart()与ajaxStop()方法(实例讲解)
- 【jQuery】使用ajaxStart()和ajaxStop()方法
- jQuery的ajaxStart方法和ajaxStop方法
- ajaxError, ajaxComplete, ajaxSend, ajaxStart, ajaxStop, ajaxSuccess的语法及返回函数
- TextureRect类
- NSTimer的使用Demo
- Simple way to identify iOS user agent in a jQuery if/then statement?
- 欢迎使用CSDN-markdown编辑器
- weblogic启动外壳
- jquery::ajaxStop() versus jquery::ajaxComplete()
- Leetcode高频题频率表(转载)
- [Unity3D]U3D开发项目总结(转)
- Android服务开发经验——优雅地活着
- Codeforces Round #301 (Div. 2) 解题报告(ABCD)
- Leetcode Freq 2
- IM即时通讯实现原理
- Leetcode Freq 3
- Leetcode Freq 4,5