JQuery $ .ajax (); asynchronous access to the full parameter $ .ajax complete parameter

$ .Ajax complete parameter

 

Method of parameter jquery ajax

url:

Requirements for the type String parameter (the default address of this page) address of the request.

type:

String parameter type requirements, request method (POST or get) defaults to get. Note that other http request method, such as put and delete can also be used, but only part of the browser supports.

timeout:

Number parameter type requirements, set request time (in milliseconds). This setting overrides $ .ajaxSetup () method of the global settings.

async:

Requirements Boolean type parameter defaults to true, all requests are asynchronous requests. If you need to send a synchronization request, set this option to false. Note that the synchronization request will lock the browser, the user must wait for another request to complete before the operation can be performed.

cache:

Boolean type parameter is required, the default is true (as when dataType Script, the default is false), is set to false information will not load request from the browser cache.

data:

Object type String requirements or parameters, data sent to the server. If you have not a string, it will automatically be converted to string format. get request will be appended to the url. Prevent this automatic conversion, you can view processData options. Object must key / value format, for example:

{
    foo1:"bar1",
    foo2:"bar2"
}

=>&foo1=bar1&foo2=bar2。

//如果是数组,JQuery将自动为不同值对应同一个名称。例如
 
{
    foo:["bar1","bar2"] } => &foo=bar1&foo=bar2。

dataType:

Requirements for the parameter of type String, the expected data type returned by the server. If not specified, will automatically return JQuery responseXML or http responseText The mime information packet, and the callback function passed as parameters. Available types are as follows:

  • xml: returns an XML document, available JQuery process.
  • html: Returns the HTML plain text information; script tag contained performs when inserted DOM.
  • script: return plain text JavaScript code. It does not automatically cached results. Unless the cache parameter sets. Note that when the remote request (not in the same domain under), all post requests are converted to get the request.
  • json: returns JSON data.
  • jsonp: JSONP format. When using the form SONP call functions,
    such as myurl? Callback = ?, JQuery will automatically replaced after a "?" Is the correct name of the function to execute the callback function.
  • text: Returns the plain text string.

beforeSend:

Function type parameter is required, the function may be modified before sending a request XMLHttpRequest object, such as adding custom HTTP header. Returns false if the beforeSend can cancel the ajax request. The XMLHttpRequest object is the only parameter.

function(XMLHttpRequest){    
    this;   //调用本次ajax请求时传递的options参数 }

complete:

Function requirements for the type of parameters, request a callback function to call when completed (requests are called when the success or failure). Parameters: XMLHttpRequest object and a type description string successful request.

function(XMLHttpRequest, textStatus){
    this;    //调用本次ajax请求时传递的options参数 }

success:

Function requirements for the type of parameters, the callback function to call when the request is successful, there are two parameters.
(1) returned by the server, and performs data processing in accordance with the dataType parameter.
String (2) described state.

function(data, textStatus){
    //data可能是xmlDoc、jsonObj、html、text等等
    this; //调用本次ajax请求时传递的options参数 }

error:

Function type parameter is required, the function is called when the request fails. This function takes three parameters, i.e., XMLHttpRequest object, an error message, error trapping object (optional). ajax event functions as follows:

function(XMLHttpRequest, textStatus, errorThrown){
  //通常情况下textStatus和errorThrown只有其中一个包含信息
  this; //调用本次ajax请求时传递的options参数 }

contentType:

String parameter type requirements, when transmission information to the server, the content default encoding type "application / x-www-form-urlencoded". The default value is suitable for most applications.

data filter:

Function type parameter requirements, to the raw data returned by the function Ajax pretreatment. Provide data and type two parameters. Ajax data is raw data returned, type dataType parameter is provided when calling jQuery.ajax. The value returned by jQuery further processing.

function(data, type){
    //返回处理后的数据
    return data; }

data filter:

Function type parameter requirements, to the raw data returned by the function Ajax pretreatment. Provide data and type two parameters. Ajax data is raw data returned, type dataType parameter is provided when calling jQuery.ajax. The value returned by jQuery further processing.

function(data, type){
    //返回处理后的数据
    return data; }

global:

Requirements for the type Boolean parameter, the default is true. It indicates whether to trigger a global ajax event. Set to false will not trigger a global ajax event, ajaxStart or ajaxStop ajax be used to control a variety of events.

ifModified:

Requirements for the type Boolean parameter, the default is false. To obtain new data only when the server data changes. Server data change judgment based on the Last-Modified header information. The default value is false, ignoring the header information.

jsonp:

Requirements parameter of type String, rewrite in the name of a callback function jsonp request. "? Callback =" This value is used to replace the GET or POST request in which the URL parameters in the "callback" section, e.g. {jsonp: 'onJsonPLoad'} will cause "onJsonPLoad =?" To the server.

username:

String parameter type requirements, in response to the user name for HTTP access authentication request.

password:

String parameter type requirements, in response to a password authentication HTTP access request.

processData:

Requirements for the type Boolean parameter, the default is true. By default, data transmission will be converted to an object (from a technical point of view is not a string) to match the default content type "application / x-www-form-urlencoded". If you want to send a DOM tree information or other undesirable information conversion, set to false.

scriptCharset:

String parameter type requirements, only when the request is dataType "jsonp" or "script", and GET is only type for forcibly modifying the character set (charset). Not normally used in both local and remote content encoding.

$(function(){
    $('#send').click(function(){ $.ajax({ type: "GET", url: "test.json", data: {username:$("#username").val(), content:$("#content").val()}, dataType: "json", success: function(data){ console.log(data); } }); }); });

Method of parameter jquery ajax

url:

Requirements for the type String parameter (the default address of this page) address of the request.

type:

String parameter type requirements, request method (POST or get) defaults to get. Note that other http request method, such as put and delete can also be used, but only part of the browser supports.

timeout:

Number parameter type requirements, set request time (in milliseconds). This setting overrides $ .ajaxSetup () method of the global settings.

async:

Requirements Boolean type parameter defaults to true, all requests are asynchronous requests. If you need to send a synchronization request, set this option to false. Note that the synchronization request will lock the browser, the user must wait for another request to complete before the operation can be performed.

cache:

Boolean type parameter is required, the default is true (as when dataType Script, the default is false), is set to false information will not load request from the browser cache.

data:

Object type String requirements or parameters, data sent to the server. If you have not a string, it will automatically be converted to string format. get request will be appended to the url. Prevent this automatic conversion, you can view processData options. Object must key / value format, for example:

{
    foo1:"bar1",
    foo2:"bar2"
}

=>&foo1=bar1&foo2=bar2。

//如果是数组,JQuery将自动为不同值对应同一个名称。例如
 
{
    foo:["bar1","bar2"] } => &foo=bar1&foo=bar2。

dataType:

Requirements for the parameter of type String, the expected data type returned by the server. If not specified, will automatically return JQuery responseXML or http responseText The mime information packet, and the callback function passed as parameters. Available types are as follows:

  • xml: returns an XML document, available JQuery process.
  • html: Returns the HTML plain text information; script tag contained performs when inserted DOM.
  • script: return plain text JavaScript code. It does not automatically cached results. Unless the cache parameter sets. Note that when the remote request (not in the same domain under), all post requests are converted to get the request.
  • json: returns JSON data.
  • jsonp: JSONP format. When using the form SONP call functions,
    such as myurl? Callback = ?, JQuery will automatically replaced after a "?" Is the correct name of the function to execute the callback function.
  • text: Returns the plain text string.

beforeSend:

Function type parameter is required, the function may be modified before sending a request XMLHttpRequest object, such as adding custom HTTP header. Returns false if the beforeSend can cancel the ajax request. The XMLHttpRequest object is the only parameter.

function(XMLHttpRequest){    
    this;   //调用本次ajax请求时传递的options参数 }

complete:

Function requirements for the type of parameters, request a callback function to call when completed (requests are called when the success or failure). Parameters: XMLHttpRequest object and a type description string successful request.

function(XMLHttpRequest, textStatus){
    this;    //调用本次ajax请求时传递的options参数 }

success:

Function requirements for the type of parameters, the callback function to call when the request is successful, there are two parameters.
(1) returned by the server, and performs data processing in accordance with the dataType parameter.
String (2) described state.

function(data, textStatus){
    //data可能是xmlDoc、jsonObj、html、text等等
    this; //调用本次ajax请求时传递的options参数 }

error:

Function type parameter is required, the function is called when the request fails. This function takes three parameters, i.e., XMLHttpRequest object, an error message, error trapping object (optional). ajax event functions as follows:

function(XMLHttpRequest, textStatus, errorThrown){
  //通常情况下textStatus和errorThrown只有其中一个包含信息
  this; //调用本次ajax请求时传递的options参数 }

contentType:

String parameter type requirements, when transmission information to the server, the content default encoding type "application / x-www-form-urlencoded". The default value is suitable for most applications.

data filter:

Function type parameter requirements, to the raw data returned by the function Ajax pretreatment. Provide data and type two parameters. Ajax data is raw data returned, type dataType parameter is provided when calling jQuery.ajax. The value returned by jQuery further processing.

function(data, type){
    //返回处理后的数据
    return data; }

data filter:

Function type parameter requirements, to the raw data returned by the function Ajax pretreatment. Provide data and type two parameters. Ajax data is raw data returned, type dataType parameter is provided when calling jQuery.ajax. The value returned by jQuery further processing.

function(data, type){
    //返回处理后的数据
    return data; }

global:

Requirements for the type Boolean parameter, the default is true. It indicates whether to trigger a global ajax event. Set to false will not trigger a global ajax event, ajaxStart or ajaxStop ajax be used to control a variety of events.

ifModified:

Requirements for the type Boolean parameter, the default is false. To obtain new data only when the server data changes. Server data change judgment based on the Last-Modified header information. The default value is false, ignoring the header information.

jsonp:

Requirements parameter of type String, rewrite in the name of a callback function jsonp request. "? Callback =" This value is used to replace the GET or POST request in which the URL parameters in the "callback" section, e.g. {jsonp: 'onJsonPLoad'} will cause "onJsonPLoad =?" To the server.

username:

String parameter type requirements, in response to the user name for HTTP access authentication request.

password:

String parameter type requirements, in response to a password authentication HTTP access request.

processData:

Requirements for the type Boolean parameter, the default is true. By default, data transmission will be converted to an object (from a technical point of view is not a string) to match the default content type "application / x-www-form-urlencoded". If you want to send a DOM tree information or other undesirable information conversion, set to false.

scriptCharset:

String parameter type requirements, only when the request is dataType "jsonp" or "script", and GET is only type for forcibly modifying the character set (charset). Not normally used in both local and remote content encoding.

$(function(){
    $('#send').click(function(){ $.ajax({ type: "GET", url: "test.json", data: {username:$("#username").val(), content:$("#content").val()}, dataType: "json", success: function(data){ console.log(data); } }); }); });

Guess you like

Origin www.cnblogs.com/Ferda/p/11427612.html