function(XMLHttpRequest) { this; /*This keyword here is used to access the options parameter object of the .ajax() method*/ } complete: Event after the request is completed, whether the request is successful or not, this event will be triggered. function(XMLHttpRequet, textStatus) { this; /*This keyword here is used to access the options parameter object of the .ajax() method*/ } textStatus parameter returns the execution status of the current request (succss and error, etc.) success: Event when the request is executed successfully. function(data, textStatus) { this; /*This keyword here is used to access the options parameter object of the .ajax() method*/ } error: Events when request execution fails function(XMLHttpRequest, textStatus, errorThrown) { this; /*This keyword here is used to access the options parameter object of the .ajax() method*/ } global: Whether to trigger global Ajax events. This attribute is of Boolean type and the default value is false
$(document).ready(function(){ $("#refresh").click(function(){ /* The URL of the page to be accessed, according to your Make corresponding modifications according to the actual situation*/ var url = "http://www.sogou.com"; $("#commentList").load(url); //Load the corresponding content } ); });
5: The $.get() method is a global method, which uses the GET method To make an asynchronous request, the syntax format is as follows:
<%@ Page Language="C#" %> <% /* * Add some data to the array respectively, * These data usually come from Database, * This is just a simulation, statically added */ string[] blogClass = { "CSS", "CSS", ".NET", ".NET", ".NET" , ".NET" }; string[] blogTitle = { "Padding in CSS", "Introduction to CSS", "Classes in C#", "Basic knowledge of C#", "C# object-oriented", "C# Design Pattern" };
string key = Request["key"]; //Get the keyword of the request server /* * Traverse the array collection */ for (int i = 0; i < blogClass.Length; i ) { /* * If the keyword is empty, display all records * If the keyword is equal to the category name , display the records under this category ;> & Lt; div & gt; & lt; span & gt; & lt;%= blogclass [i]%& gt; & lt;/span & lt;%= blogtitle [i]%& gt; /div & div & gt; <; > var xmlReq = $.post(url, [data], [callback], [type]); The $.get() method submits data in GET mode, and all parameter information will be appended to the URL. Web requests generally have certain restrictions on URL length, so the data length passed by the $.get() method also has a certain upper limit. The $.post() method sends parameters to the server as the entity of the message. For The data length is not affected.
10: serializeArray() method This method serializes the page form into a JSON structured object, which is in the form of a collection of "key/value" pairs Encapsulates all element values in the form. Note here that this method returns a JSON object, not a JSON string The structure of the JSON object is as follows:
" , "value": "value2"}, ); var textName = jsonData[0].name; var textValue = jsonData[0].value;
11: Set global Ajax default options
In applications, a large number of Ajax methods are often written to implement various functions. Each time, a large number of parameters are set in the $.ajax() method, which is very inconvenient. jQuery provides $.ajaxSetup () method, you can set global Ajax default parameter items. $.ajaxSetup([options]);
global: false, //Disable triggering of global events dataType: 'json', error: function(xhr, textStatus, errorThrown) { ; 🎜>
ajaxComplete(callback); //This event is triggered when the request is completed ajaxError(callback); //This event is triggered when an error occurs in the request ajaxSend(callback); //The request is sent This event is triggered before ajaxStart(callback); //This event is triggered when the request starts ajaxStop(callback); //This event is triggered when the request ends ajaxSuccess(callback); //Triggered when the request is successful The event handler of the
ajaxStart() method and ajaxStop method is a parameterless function, and the rest can have 3 parameters. The syntax format is as follows: Copy the code The code is as follows:
Function (Event, XHR, SETTINGS) { EVENT is a triggered event object XHR is the XMLHTTPRequest object Settings are Ajax request configuration parameters
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