Jquery-ajax-async
来源:互联网 发布:mac的numbers使用教程 编辑:程序博客网 时间:2024/05/22 07:44
jQuery同步问题:
google chrome浏览器给出的结果是:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check .
jQuery 官网给出的结果是:
async (default: true)
Type: Boolean
By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().
原文地址:
http://api.jquery.com/jQuery.ajax/
参考网址:
http://xhr.spec.whatwg.org/.
一下转摘的一篇关于‘jQuery jqXHR对象的属性和方法’的文章
原文地址:http://www.365mini.com/page/jquery-jqxhr-object.htm
在 jQuery 1.4 之前(包括1.4),$.ajax()方法返回的是浏览器原生的XMLHttpRequest对象。
从 jQuery 1.5 开始,$.ajax()
方法返回jQuery自己的XMLHttpRequest对象(一般简称jqXHR)。之所以这样做,是因为 jQuery 1.5 引入了延迟对象jQuery.Deferred,以便于更好地处理和执行回调函数。
你可以简单地理解为jqXHR对象是jQuery自己伪造的一个XMLHttpRequest对象和$.Deferred对象的结合体。
jqXHR是浏览器原生XMLHttpRequest对象的超集。例如,它也包含responseText
和responseXML
属性,以及getResponseHeader()
方法。当传输机制与 XMLHttpRequest 对象不同时(例如,用一个<script>标签来完成JSONP请求),jqXHR对象会尽可能地模拟本地 XMLHttpRequest 对象的功能。
从jQuery 1.5.1开始,jqXHR
对象也overrideMimeType()
方法(它在 1.4.x 中也可用,但在 1.5 中被临时移除)。overrideMimeType()
方法可用于beforeSend()
的回调函数中,比如用来修改 Content-Type 响应头。
从jQuery 1.5开始,$.ajax()
返回的jqXHR对象实现了Promise接口,包括其所有的属性、方法和行为。因此,我们通过jqXHR可以非常简单地为本次$.ajax()
绑定AJAX请求对应状态执行的回调函数。
我们通过解剖一个完整的jqXHR对象,来了解jqXHR对象的属性和方法:
var jqXHR = { abort: function (statusText){ // 取消请求,关闭连接 }, always: function (){ // 设置请求完成(无论成功或失败)时需要执行的一个或多个回调函数 }, complete: function (){ // always()函数的别名,设置请求完成(无论成功或失败)时需要执行的一个或多个回调函数 }, done: function (){ // 设置请求成功时需要执行的一个或多个回调函数 }, error: function (){ // fail()函数的别名,设置请求失败时需要执行的一个或多个回调函数 }, fail: function (){ // 设置请求失败时需要执行的一个或多个回调函数 }, getAllResponseHeaders: function (){ // 获取响应头信息的原始字符串 }, getResponseHeader: function (key){ // 获取响应头中指定名称的值 }, overrideMimeType: function (type){ // 重写 Content-Type响应头 }, pipe: function (){ // then()函数的别名,分别设置请求成功、失败、正在进行时需要执行的回调函数 }, progress: function (){ // 设置Deferred对象生成进度通知时需要执行的回调函数 }, promise: function (obj){ // 为指定对象追加Promise对象的成员,以充当Promise对象 }, readyState: 4, // 请求的状态 responseText: "<!DOCTYPE html><html>......</html>", // 响应的文本内容 setRequestHeader: function (name, value){ // 设置请求头 }, state: function (){ // 确定一个Deferred对象的当前状态,例如:"pending"、"resolved"、"rejected" }, status: 200, statusCode: function (map){ // 设置响应指定状态码需要执行的回调函数 // map形如:{ 301:function(){}, 404:function(){} } }, statusText: "OK", // 状态响应头中的描述文本 success: function (){ // done()函数的别名,设置请求成功时需要执行的一个或多个回调函数 }, then: function (){ // 分别设置请求成功、失败、正在进行时需要执行的回调函数 }};
- jquery ajax的async
- jQuery AJAX async false
- jquery的$.ajax async
- Jquery-ajax-async
- jquery ajax async
- 基于jquery的$.ajax async使用
- 基于jquery的$.ajax async使用
- 基于jquery的$.ajax async使用
- jquery ajax属性async(同步异步)示例
- jQuery异步请求ajax()之async详解
- $.ajax async
- $.ajax async
- jquery中$.Ajax()async和success在异步处理 编辑
- 关于jquery中$.Ajax()async和success在异步处理
- jquery利用async在ajax中给全局变量赋值
- jQuery:AJAX知识点及async同步异步的区别
- 【.Net码农】基于jquery的$.ajax async使用
- jQuery的ajax async同步和异步介绍
- PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- YTU 2800: 逗逗泡泡的保密电文
- Spinner的常用技巧
- iOS抽屉效果
- 知识片段---弹簧动画
- Jquery-ajax-async
- 项目修炼之路(2)测试-TCPCopy
- 使用HttpUrlConnection进行post请求上传文件
- matlab出现Invalid file identifier. Use fopen to generate a valid file identifier错误
- HDU 1242 Rescue (BFS or DFS)
- ionic02-----列表新闻的获取
- 基于 java nio 长连接实现的聊天室
- 知识片段---表判断是处于上划还是下滑
- Android ListView点击展开收起效果(一)