jquery jsonp异步请求,success和jsonpCallback的区别
来源:互联网 发布:东莞数控编程招聘信息 编辑:程序博客网 时间:2024/05/18 02:12
jquery jsonp异步请求,success和jsonpCallback的区别
$.ajax({
url:
type: ‘GET’,
dataType: ‘jsonp’,
success:getGoodsList
});
$.ajax({
url:
type: ‘GET’,
dataType: ‘jsonp’,
jsonpCallback:getGoodsList
});
success
Type: Function( Anything data, String textStatus, jqXHR jqXHR )
A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter or the dataFilter callback function, if specified; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.
jsonpCallback
Type: String or Function()
Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it’ll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function.
循环调用ajax的时候,由于循环的结果参数都在变化,如果回调函数需要获取调用ajax时作用域空间的值,则使用success,
如果使用jsonpCallback,获取值可能会混乱。
- jquery jsonp异步请求,success和jsonpCallback的区别
- 【本文完全转载】JSON和JSONP的大概原理,以及jquery中ajax的jsonp、jsonpCallback方法的描述
- ajax JSONP请求 处理回调函数的注意:jsonpCallback是区分大小写
- java结合jQuery的ajax异步发起jsonp请求
- jQuery 中 ajax 的 complete 和 success 有什么区别
- 同步请求和异步请求的区别
- 同步请求和异步请求的区别
- 同步请求和异步请求的区别
- 同步请求和异步请求的区别
- 同步请求和异步请求的区别
- 同步请求和异步请求的区别
- 同步请求和异步请求的区别
- jQuery.ajax中success 和complete 区别
- jQuery.ajax中success 和complete 区别
- jQuery.ajax中success 和complete 区别
- jquery 同步和异步的请求方式
- Jquery的同步和异步请求
- Jquery的同步和异步请求
- IOS_Swift_深入理解闭包 对比懒加载和普通赋值的区别
- “互联网+”并非要干掉传统企业|“娃娃亲亲”创始人郑国新
- 1056. Mice and Rice (25)
- 学习编程的经历和感受
- 【STL学习】算法篇
- jquery jsonp异步请求,success和jsonpCallback的区别
- ACM 用1-9组成的三个三位数,比例为1:2:3
- NYOJ 1132 promise me a medal (判断两线段是否相交)
- Objective-C新特性
- NDK安装配置
- 打开了新世界的大门,自我总结
- 收藏
- JavaEE_Mybatis_SpringMVC_Mybatis_lesson3_ Mapper代理的开发方式
- 文件的上传和下载