The meaning of parameters in JQuery Ajax

Source: Internet
Author: User

All options are optional and the following is a brief description of each option

1.async

The default is true, which is the request for an asynchronous request, which is the meaning of Ajax presence. However, you can also set this parameter to False to implement a synchronous request. (The sync request will lock the browser until the request is complete before you can perform other actions)

2.bforeSend (XHR)

This method is used to modify the XMLHttpRequest object before sending the request, and if the modification fails to return false, the AJAX request is canceled;

3.cache

The default is true, which is set to false to not cache. (Default to Fasle when datatype is script or JASONP)

4.complete (Jqxhr,textstatus)

The callback function after the request is completed, whether successful or not. Textstatus is a string that describes the request type, which can have the following value Success,notmodified,error,timeout,abort,parsererror.

5.contents

jQuery1.5 added. A map of a string or regular expression used to determine how to handle the response of jquery.

6.contentType

It is the content encoding type of the amount of data sent to the server, and its default value is "appliction/x-www-form-urlencoded". The data that is passed to the server is usually encoded in UTF-8.

7.context

The context used to set the AJAX callback function. Let this object be pointed to in the callback function.

8.converters

jQuery1.5 added. A set of data types to convert to data types. Each conversion value is a method that returns the response converted value.

9.crossDomain

False indicates the same domain request, and True indicates a cross-domain request. It enables the server end multiplicity to be directed to another domain.

10.data

Data sent to the server. Must be a key/value format. and automatically converted to a query String,get request appends the string to the URL.

11.dataFilter (Data,type)

The function of preprocessing the return value of Ajax, data is the return value, Teype is the datatype parameter passed.

12.dataType

Expected data type returned by the server. If not specified, it is automatically determined based on the MIME information in the HTTP packet. The available values are xml,html,script,json,jsonp,text.

13.error (Jqxhr,textstatus,errorthrown)

This method is called when the request fails. Textstatus is an error message and the available value is error,timeout,abort,parsererror. The Errorthrown is optional for the exception object to be captured.

14.global

The default is true to trigger global AJAX events. Set to False to be used without triggering. Can be used to control different AJAX events.

15.headers

jQuery1.5 added. A map of the additional key/value pairs that are used to make requests together. This needs to be set before the Beforesend method is called, because any value in headers has the Ken that is overridden in the Beforesend method.

16.ifModified

The default is false, which only gets the data when the server data changes, using the Last-modified header information in the HTTP packet.

17.isLocal

jQuery1.5.1 added. Allowing the current environment to be recognized as local,jquery is not recognized by default. File,*-extension and widget protocols can be identified as local. It is recommended to use the $.ajaxsetup () method if islocal needs to be modified.

18.jsonp

Restarts the name of the callback function in the JSONP request. This value is used instead of "callback=?" "The callback part of the URL parameter in this request.

19.jsonpCallback

Specifies a callback function name for the JSONP request. jquery automatically generates a random function name, which can be modified with this value.

20.mimetype

jQuery1.5.1 added. Can be used to overwrite the mimetype in XHR.

21.password

The password used to respond to HTTP access authentication requests.

22.processData

The default is true. You can modify the data type passed to match the type of contenttype. False is not modified.

23.scriptCharset

The charset is used to force modification only if the request is JSONP or script, and type is get.

24.statusCode

jQuery1.5 added. The handler function that defines the return code for the HTTP. The following example defines the processing method after returning 404.

[JavaScript]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. $.ajax ({
    2. StatusCode: {
    3. 404: function () {
    4. Alert ("page not Found");
    5. }
    6. }
    7. });
25.success (DATA,TEXTSTATUS,JQXHR)

The callback function after the request succeeds. Parameters are returned by the server and are handled according to the datatype parameter.

26.timeout

Sets the request time-out period, in milliseconds. This setting overrides the global setting, that is, all AJAX requests share the same time-out.

27.traditional

Set to True to serialize the data in a traditional way.

28.type

Request method, get or post or put or delete. The default is get. Put and delte are not supported by all browsers.

29.url

The address where the request was sent. Empty represents the current page.

30.username

The user name used to respond to HTTP access authentication requests. Paired with password.

31.xhr

The default is ActiveXObject under IE and other browsers are xmlhttprequest. Used to override or provide an enhanced XMLHttpRequest object.

32.xhrFields

jQuery1.5.1 added. It can be added to the key/value pair on the native XHR object. As an example, you can set the cross-domain withcredentials to true by using it.

[JavaScript]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. $.ajax ({
    2. Url:a_cross_domain_url,
    3. Xhrfields: {
    4. Withcredentials: True
    5. }
    6. });

In jQuery1.5, the Withcredentials attribute is not in the native XHR, so the request is ignored. To test this example, you need to use jQuery1.5.1.

Detailed documentation Jquery.ajax English documents

"Reprint" http://blog.csdn.net/supersky07/article/details/7431721

The meaning of parameters in JQuery Ajax

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.