jquery Operation Ajax-related methods

Source: Internet
Author: User
Tags getscript browser cache

Jquery.get ()
Loads data from the server using an HTTP GET request.
Jquery.get (URL [, data] [, Success (DATA,TEXTSTATUS,JQXHR)] [Dtatype])
URL a URL that contains the sending request
Data sent to the server after the string key value pair
Success () The callback function when the request succeeds
DataType the expected data returned from the server.
Usage:
$.get ("test.cgi", {name: "John", Time: "2pm"},
function (data) {
Alert ("Data Loaded:" + data);
});


Jquery.getjson ()
Loads JSON-encoded data using an HTTP GET request server.
Jquery.getjson (URL [, data] [, Success (DATA,TEXTSTATUS,JQXHR)])
URL a URL that contains the sending request
Data sent to the server after the string key value pair
Success () The callback function when the request succeeds


Jquery.getscript ()
Loads and executes a JavaScript file from the server using an HTTP GET request.
Jquery.getscript (Url[success (SCRIPT,TEXTSTATUS,JQXHR))
URL a URL that contains the sending request
Data sent to the server after the string key value pair
Usage:
$.getscript ("Ajax/test.js", function (data, textstatus, JQXHR) {
Console.log (data); Data returned
Console.log (Textstatus); Success
Console.log (Jqxhr.status); 200
Console.log (' Load was performed. ');
});


Jquery.post ([Settings])
Loads data from the server using an HTTP POST request.
Jquery.post (url[,data][,success (DATA,TEXTSTATUS,JQXHR)][,datatype])
URL a URL that contains the sending request
Data sent to the server after the string key value pair
Success () The callback function when the request succeeds
Usage:
$.post ("test.php", {name: "John", Time: "2pm"},
function (data) {
Alert ("Data Loaded:" + data);
});


. Load ()
Loads the data from the server and inserts the returned HTML code into the matching element.
. Load (Url[,data][,complete (responsetext,textstatus,xmlhttprequest))
URL a URL that contains the sending request
Data sent to the server after the string key value pair
Complete the callback function when the request succeeds
Usage:
$ (' #result '). Load (' ajax/test.html #container ');


Jquery.ajax ()
Executes an asynchronous HTTP (Ajax) request.
Parameters:
URL type: Sting send the requested address (default current page)
Type: Sting (default = Get) Request mode ("POST" or "get")
Timeout Type: Number sets the request time-out (in milliseconds), which overrides the global setting by default.
Async Type: Boolean default setting (TRUE) all requests in the default setting are one-step requests, and set to False if synchronization requests are required.
Beforesend type: Functions that can modify the XMLHttpRequest object before a function sends a request, such as adding a custom HTTP header. The XMLHttpRequest object is the only parameter.
Cache Type: Boolean default is (True) set to False to not load request information from the browser cache.
Complete type: The function request is completed after the callback functions, (called when the request succeeds or fails) parameters: XMLHttpRequest Object, Success information string. function (XMLHttpRequest, textstatus) {this;//the options for this AJAX request}
The contenttype type is: string sends information to the server when the content encoding type, the default value for most applications.
Data type: An Object String that is sent to the server. is automatically converted to the request string format, and the GET request is appended to the URL
DataType Type: string expects the data type returned by the server, and "XML" returns an XML document. HTML returns plain text information that contains the script element. Script returns plain text JavaScript code and does not automatically cache results. "JSON" returns a JSON array. "JSONP" JSONP format.
Error Type: This method is called when a function request fails.
Global type: Boolean whether to trigger an overall Ajax event. The default of (true) setting to false will not trigger global AJAX events and can be used to control different AJAX events.
Ifmodified Type: Boolean defaults to False to obtain new data only when the server data changes.
ProcessData Type: Boolean by default (TRUE) the data sent by default is converted to an object (technically not a string) to match the default content type "application/x-www-form-urlencoded" 。 Set to False if you want to send DOM tree information or other information that you do not want to convert.
Success Type: The callback function after the function request succeeds. This method has two parameters: the server returns the data and returns the status.
$ (document). Ready (function () {
JQuery ("#clearCac"). Click (function () {
Jquery.ajax ({
URL: "/handle/do.aspx",
Type: "Post",
Data: {ID: ' 0 '},
DataType: "JSON",
Success:function (msg) {
Alert (msg);
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
alert (xmlhttprequest.status);
alert (xmlhttprequest.readystate);
alert (textstatus);
},
Complete:function (XMLHttpRequest, Textstatus) {
This Options parameters passed when calling this Ajax request
}
});
});
});


The first parameter returned by the error event XMLHttpRequest has some useful information:
Xmlhttprequest.readystate:

Status code

0-(uninitialized) has not yet called the Send () method

1-(load) called the Send () method, sending the request

2-(loading complete) the Send () method executes and has received the full response content

3-(interactive) parsing response content

4-(complete) The response content resolution is complete and can be invoked on the client


Xmlhttprequest.status:
1xx-Information Tips
These status codes represent a temporary response. The client should be prepared to receive one or more 1xx responses before receiving a regular response.
100-Continue.
101-Switch protocol.
2xx-success
This type of status code indicates that the server successfully accepted the client request.
200-OK. The client request was successful.
201-created.
202-accepted.
203-Non-authoritative information.
204-no content.
205-Reset the content.
206-Partial content.
3xx-redirection
The client browser must take more action to implement the request. For example, the browser might have to request a different page on the server, or repeat the request through a proxy server.
301-The object has been permanently moved, that is, permanent redirection.
302-The object has been temporarily moved.
304-not modified.
307-Temporary redirection.
4xx-Client Error
An error occurred and the client appears to be having problems. For example, a client requests a page that does not exist, and the client does not provide valid authentication information. 400-Bad request.
401-access is denied. IIS defines a number of different 401 errors, which indicate a more specific cause of the error. These specific error codes are displayed in the browser, but are not displayed in the IIS log:
401.1-Login failed.
401.2-server configuration caused logon failure.
401.3-not authorized due to ACL restrictions on resources.
401.4-Filter Authorization failed.
401.5-ISAPI/CGI application authorization failed.
401.7– access is denied by the URL authorization policy on the Web server. This error code is dedicated to IIS6.0.
403-Forbidden: IIS defines a number of different 403 errors that indicate a more specific cause of the error:
403.1-execution access is forbidden.
403.2-Read access is forbidden.
403.3-Write access is forbidden.
403.4-Requires SSL.
403.5-Requires SSL128.
The 403.6-IP address is rejected.
403.7-Requires a client certificate.
403.8-site access is denied.
403.9-Excessive number of users.
403.10-Invalid configuration.
403.11-Password change.
403.12-Deny access to the mapping table.
403.13-The client certificate is revoked.
403.14-Reject directory list.
403.15-Client access permission exceeded.
403.16-Client certificate is not trusted or invalid.
403.17-The client certificate has expired or is not yet valid.
403.18-The requested URL cannot be executed in the current application pool. This error code is dedicated to IIS6.0.
403.19-CGI cannot be executed for clients in this application pool. This error code is dedicated to IIS6.0.
403.20-passport Login failed. This error code is dedicated to IIS6.0.
404-not found.
404.0-(None) – No files or directories found.
404.1-Unable to access the Web site on the requested port.
The 404.2-web service extension lockout policy blocks this request.
The 404.3-mime mapping policy blocks this request.
405-The HTTP verb used to access this page is not allowed (method not allowed)
406-The client browser does not accept the MIME type of the requested page.
407-proxy authentication is required.
412-Precondition failed.
413– request entity is too large.
414-The request URI is too long.
415– media types not supported.
The range requested by 416– is not sufficient.
417– execution failed.
423– a locked error.
5xx-Server Error
The server could not complete the request because it encountered an error.
500-Internal server error.
The 500.12-application is busy restarting on the Web server.
The 500.13-web server is too busy.
500.15-Direct Request Global.asa is not allowed.
500.16–unc authorization credentials are incorrect. This error code is dedicated to IIS6.0.
The 500.18–url authorization store cannot be opened. This error code is dedicated to IIS6.0.
500.100-Internal ASP error.
501-The header value specifies the configuration that is not implemented.
An invalid response was received when the 502-web server was used as a gateway or proxy server.
The 502.1-cgi application timed out.
502.2-CGI Application error. Application.
503-The service is not available. This error code is dedicated to IIS6.0.
The 504-gateway timed out.
505-http version is not supported.
Jquery.param ()
Creates an array, an ordinary object, or a jquery object whose serialization behaves the same as a URL query string or AJAX request.
Jquery.param (obj)
Obj an array to serialize, an ordinary object, or a jquery object.
Jquery.param (obj, Traditional)
Obj an array to serialize, an ordinary object, or a jquery object.
Traditional
A Boolean value that indicates whether the traditional "shallow" serialization was performed.
$.param ({a: [2,3,4]})//"a[]=2&a[]=3&a[]=4"
$.param ({A: {b:1,c:2}, D: [3,4,{E:5}]})//"a[b]=1&a[c]=2&d[]=3&d[]=4&d[2][e]=5"

jquery Operation Ajax-related methods

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.