$.ajax () method parameters in jquery

Source: Internet
Author: User

url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址。 type: 要求为String类型的参数,请求方式(post或get)默认为get。注意其他http请求方法,例如put和Delete can also be used, but only some browsers support it. timeout: 要求为Number类型的参数,设置请求超时时间(毫秒)。此设置将覆盖$.ajaxSetup()方法的全局设Reset async:要求为Boolean类型的参数,默认设置为 true ,所有请求均为异步请求。 如果需要发送同步请求,请将此选项设置为 false 。注意,同步请求将锁住浏览器,用户其他操作必须等The request is complete before it can be executed. cache:要求为Boolean类型的参数,默认为 true (当dataType为script时,默认为 false )。 设置为 false 将不会从浏览器缓存中加载请求信息。 data: 要求为Object或String类型的参数,发送到服务器的数据。如果已经不是字符串,将自动转换为字符串格Expression The GET request will be appended to the URL. To prevent this automatic conversion, you can view the ProcessData option. The object must be a key/value grid 式,例如{foo1: "bar1" ,foo2: "bar2" }转换为&foo1=bar1&foo2=bar2。如果是数组,JQuery将自动为不同 值对应同一个名称。例如{foo:[ "bar1" , "bar2" ]}转换为&foo=bar1&foo=bar2。 dataType: 要求为String类型的参数,预期服务器返回的数据类型。如果不指定,JQuery将自动根据http包mimeThe information returns Responsexml or ResponseText, and is passed as a callback function parameter.       可用的类型如下:            xml:返回XML文档,可用JQuery处理。            html:返回纯文本HTML信息;包含的script标签会在插入DOM时执行。            script:返回纯文本JavaScript代码。不会自动缓存结果。除非设置了cache参数。注意在远程请求(not under the same domain), all post requests are converted to get requests.            json:返回JSON数据。            jsonp:JSONP格式。使用SONP形式调用函数时,例如myurl?callback=?,JQuery将自动替换后一个“?” is the correct function name to execute the callback function.            text:返回纯文本字符串。 beforeSend:要求为Function类型的参数,发送请求前可以修改XMLHttpRequest对象的函数,例如添加自定义 HTTP头。在beforeSend中如果返回 false 可以取消本次ajax请求。XMLHttpRequest对象是惟一的参Number.              function(XMLHttpRequest){                 this ;    //调用本次ajax请求时传递的options参数              } complete:要求为Function类型的参数,请求完成后调用的回调函数(请求成功或失败时均调用)。Parameters: The XMLHttpRequest object and a string that describes the successful request type.            function(XMLHttpRequest, textStatus){               this ;     //调用本次ajax请求时传递的options参数            } success:要求为Function类型的参数,请求成功后调用的回调函数,有两个参数。           ( 1 )由服务器返回,并根据dataType参数进行处理后的数据。           ( 2 )描述状态的字符串。           function(data, textStatus){              //data可能是xmlDoc、jsonObj、html、text等等              this ;   //调用本次ajax请求时传递的options参数 error:要求为Function类型的参数,请求失败时被调用的函数。该函数有 3 个参数,即XMLHttpRequest对象、错Error message, and optionally, the wrong object to be captured.      ajax事件函数如下:         function(XMLHttpRequest, textStatus, errorThrown){            //通常情况下textStatus和errorThrown只有其中一个包含信息            this ;    //调用本次ajax请求时传递的options参数         } contentType:要求为String类型的参数,当发送信息至服务器时,内容编码类型默认 "application/x-www-form-urlencoded" 。该默认值适合大多数应用场合。 dataFilter:要求为Function类型的参数,给Ajax返回的原始数据进行预处理的函数。Provides data and type two parameters. Data is the original data returned by Ajax, and type is the datatype parameter that is provided when Jquery.ajax is called. The value returned by the function will be further processed by jquery.         function(data, type){            //返回处理后的数据            return data;         } global:要求为Boolean类型的参数,默认为 true 。表示是否触发全局ajax事件。设置为 false 将不会触发全局Ajax events, Ajaxstart or ajaxstop, can be used to control various AJAX events. ifModified:要求为Boolean类型的参数,默认为 false 。仅在服务器数据改变时获取新数据。 服务器数据改变判断的依据是Last-Modified头信息。默认值是 false ,即忽略头信息 jsonp:要求为String类型的参数,在一个jsonp请求中重写回调函数的名字。 该值用来替代在 "callback=?" 这种GET或POST请求中URL参数里的 "callback" 部分,例如 {jsonp: ‘onJsonPLoad‘ }会导致将 "onJsonPLoad=?" 传给服务器。 username:要求为String类型的参数,用于响应HTTP访问认证请求的用户名。 password:要求为String类型的参数,用于响应HTTP访问认证请求的密码。 processData:要求为Boolean类型的参数,默认为 true 。默认情况下,发送的数据将被转换为对象(从技术角度 来讲并非字符串)以配合默认内容类型 "application/x-www-form-urlencoded" 。如果要发送DOM 树信息或者其他不希望转换的信息,请设置为 false scriptCharset:要求为String类型的参数,只有当请求时dataType为 "jsonp" 或者 "script" ,并且type是GET时is used to force the modification of the character set (CharSet). Typically used when local and remote content encodings are different.  

$.ajax () method parameters in jquery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.