Home >Web Front-end >JS Tutorial >Detailed explanation and usage guide of AJAX

Detailed explanation and usage guide of AJAX

巴扎黑
巴扎黑Original
2017-07-18 15:47:561369browse


Definition and Usage
The ajaxSetup() method sets default values ​​for future AJAX requests.
Syntax
$.ajaxSetup({name:value, name:value, ... })

This parameter contains one or more name/value pairs The AJAX request specifies settings.
Possible names/values ​​are listed in the table below:
Name Value/Description
async Boolean value indicating whether the request is processed asynchronously. The default is true.
beforeSend(xhr) Function to run before sending the request.
cache Boolean value, indicating whether the browser caches the requested page. The default is true.
complete(xhr,status) Function that runs when the request is completed (called after the request succeeds or fails, that is, after the success and error functions).
contentType The content type used when sending data to the server. The default is: "application/x-www-form-urlencoded".
context specifies the "this" value for all AJAX-related callback functions.
data Specifies the data to be sent to the server.
dataFilter(data,type) Function used to process XMLHttpRequest raw response data.
dataType The expected data type of the server response.
error(xhr,status,error) Function to run if the request fails.
global Boolean value that specifies whether the global AJAX event handler is triggered for the request. The default is true.
ifModified Boolean value that specifies whether the request succeeds only if the response has changed since the last request. The default is false.
jsonp Rewrite the string of the callback function in a jsonp.
jsonpCallback Specifies the name of the callback function in a jsonp.
password Specifies the password used in HTTP access authentication requests.
processData Boolean value that specifies whether the data sent through the request is converted to a query string. The default is true.
scriptCharset specifies the requested character set.
success(result,status,xhr) Function run when the request is successful.
timeout Set the local request timeout (in milliseconds).
traditional Boolean value that specifies whether to use the traditional style of parameter serialization.
type Specifies the type of request (GET or POST).
url specifies the URL to send the request. The default is the current page.
username specifies the username used in HTTP access authentication requests.
xhr Function used to create XMLHttpRequest objects.

The above is the detailed content of Detailed explanation and usage guide of AJAX. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Introduction to JQueryNext article:Introduction to JQuery