ID ajax-div. You can even implement an AJAX operation that loads some content by making an ID, such as:$ (' #ajax-div '). Load (' data.html#my-section ');Implementing the Get and Post methodsGet (URL, [data], [callback])URL (String) to send the requested URL address.Data (MAP) (optional parameter) to be sent to the se
loads some content by making an ID, such as:$ (' #ajax-div '). Load (' data.html#my-section ');Implementing the Get and Post methodsGet (URL, [data], [callback])URL (String) to send the requested URL address.Data (MAP) (optional parameter) to be sent to the server, expressed as a Key/value key-value pair, is appended to the request URL as QueryStringCallback (callback) (optional parameter) The callback fun
jquery syntax to summarize some of the AJAX applications.
Load Static page
Load (URL, [data], [callback]); URL address of the HTML page requested by the URL (String)Data (MAP) (optional parameters) sent to the server Key/valueCallback (callback) (optional parameter) callback function when the request completes (does not need to be success)The load () method can easily load static page content into the sp
different states, for this state in the Ajax there are 5 kinds, respectively.0-(uninitialized) has not yet called the Send () method1-(load) called the Send () method, sending the request2-(loading complete) the Send () method executes,3-(interactive) parsing response content4-(complete) The response content resolution is complete and can be invoked on the clientFor the above state, where the "0" state is the state value automatically after the defin
var getxmlhttprequest = function () { try{ ///Mainstream browser provides XMLHttpRequest object return new XMLHttpRequest (); } catch (E) { ///low version of IE browser does not provide XMLHttpRequest object, IE6 below //So must use the specific implementation of IE browser ActiveXObject return new ActiveXObject ("Microsoft.XMLHTTP");} ; var xhr = Getxmlhttprequest ();//readyState 0=> initialize 1=> load 2=> load complete 3=> parse 4=> finish//Console.
varGetxmlhttprequest =function () { Try{ //XMLHttpRequest objects are available in mainstream browsers return NewXMLHttpRequest (); }Catch(e) {//The lower version of IE does not provide XMLHttpRequest objects, IE6 the following //so you must use the specific implementation of IE browser ActiveXObject return NewActiveXObject ("Microsoft.XMLHTTP"); }};varXHR =getxmlhttprequest ();//readyState 0=> initialization 1=> loading 2=> loading complete 3=> parsing 4=> complet
statistics.$ (' #stats '). Load (' stats.html '); Typically, you might want to pass some parameters to a server-side page. You might have guessed that using jquery would be very easy. You can choose to use $.post () or $.get (), depending on your specific needs, of course. If necessary, you can pass an optional data object and a callback function. Listing4 is a simple example of sending data and using call
var getxmlhttprequest = function () { try{ ///Mainstream browser provides XMLHttpRequest object return new XMLHttpRequest (); } catch (E) { ///low version of IE browser does not provide XMLHttpRequest object, IE6 below //So must use the specific implementation of IE browser ActiveXObject return new ActiveXObject ("Microsoft.XMLHTTP");} ; var xhr = Getxmlhttprequest ();//readyState 0=> initialize 1=> load 2=> load complete 3=> parse 4=> finish//Console.
First look at the following section of code, and then give you a detailed introduction, Ajax in the readystate (status value) and status (status code), the specific content is as follows:var getxmlhttprequest = function () {try{//
settings and callback and write $. ajax or $. get in the interaction event. Call $. loader (key). show () before the request, and call $. loader (key). hide () in the callback function (). In this way, you can flexibly control the loading status.
ExampleCopy codeThe Code is as follows: $ ('# getuserinfo'). bind ('clic
Differences between readyState and status of jQuery Ajax and detailed instructions for use, jqueryreadystate
In the previous articles, I analyzed ajax Asynchronization and synchronization of jquery and some exception handling. I feel that I haven't made clear the
write $. ajax or $. get in the interaction event. Call $. loader (key). show () before the request, and call $. loader (key). hide () in the callback function (). In this way, you can flexibly control the loading status.ExampleCopy codeThe Code is as follows:$ ('# GetUserInfo'). bind ('click', function (){$. Loader ('userinfo'). request ();}); You can also re-wr
Copy Code code as follows:
$.post ("data.php", $ ("#firstName. Val ()"), function (data) {
$ ("#postResponse"). HTML (data.name);
"JSON"//Set the type of get data, so the data format is JSON type
);
three, $.ajax (Opiton)
Description: $.ajax
developed a jquery plugin called Ajax request Status Manager. Using this plugin can make loading less troublesome. You can use the plugin to add all the requests in advance before triggering the AJAX request, and all you have to do is execute it in the event that the user interacts. Request () method. You can set all
Today saw the group inside the Netizen asked the jquery Ajax (Load,post,get,ajax) between the difference, now collated an article out, hope can help netizens, first we first look at some simple method,These are methods that encapsulate Jquery.ajax () to facilitate our use, and of course, if you are dealing with complex
the Textstatus and Errorthown has a value
This ; //The options for this AJAX request
}
Global
Boolean
(default: TRUE) triggers a global AJAX event. Set to false will not trigger global AJAX events.such as Ajaxstart or Ajaxstop. Can be used to control different AJ
In this paper, the use of $.get (), $.post (), $.ajax (), $.getjson () in jquery is summarized in detail, the need for friends can be consulted, I hope to help you.read more about jquery each Ajax function: $.get (), $.post (), $.
This article is for jquery in $.get (), $.post (), $.ajax (), $.getjson () with a detailed summary of the introduction, the need for friends can come over to the reference, I hope to be helpful to everyoneRead more about Jquery's various Ajax functions:$.get (), $.post (), $
This article is about $. get (), $. post (), $. ajax (), $. the usage of getJSON () is summarized in detail. If you need it, you can refer to it for help.
Details about Jquery Ajax functions:$. Get (), $. post (), $. ajax (), $. g
, if not set, and $. Get () returns the same format as the string.Copy the Code code as follows:$.post ("data.php", $ ("#firstName. Val ()"), function (data) {$ ("#postResponse"). HTML (data.name);}, "JSON"//sets the type of get data, so the resulting data format is JSON-type);Sam, $.
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:
[email protected]
and provide relevant evidence. A staff member will contact you within 5 working days.