$.get (): Asynchronous request with Get method
$.get (url,data/{"param1": "Pamaram1value",},callback,type)
The callback of the $.get () method has only two parameters:
function (data,textstatus) {
Data
Textstatus
}
The data parameter represents the content returned by the request, and Textstatus represents the status of the return request
Returns the XML document: When the data format returned by the server side is an XML document, the returned data needs to be processed, as is the case with XML documents and HTML documents, as well as with the regular Attri (). Find (). Fliter () and other methods, the jquery code is as follows:
$ (function () {
$ ("selector"). Click (function () {
$.get ("url", {
param1:$ ("#param1"). Val (),
param2:$ ("#param2"). Val ()
},function (data,textstatus) {
var para1=data.param1;
var para2=data.param2;
var txthtml= "<div class= ' para1 ' >" +para1+ "</div>"
},json);
})
})
$.getscript () and $.getjson ()
$ (function () {
$ ("selector"). Click (function () {
$.getscript (' Test.js ')
})
})
$.getjson (), for loading JSON files
You can iterate through the data variables in the function, or you can use iterations to build the appropriate HTML code for each item, although it can also be implemented with a traditional for loop, jquery provides a common traversal method $.each (), which can be used to traverse objects and arrays, $. The each () function differs from the each () method of the JQuery object, which is a global function that does not manipulate the jquery object, but rather takes the first as the index of the object's member or array, and the second is the corresponding variable or content
$ (function () {
$ ("selector"). Click (function (data) {
$ ("selector"). empty ();
var html= "";
$.each (Data,function (commentindex,comment) {
html+= ' <div class= "comment" >
})
})
})
jquery and Ajax