The simplest of the three data formats is the html format, which can be directly used after return. The preceding processing method is the json Processing Method of xml.
1. html processing is relatively simple and can be output directly.
$ ("Jb51p"). innerHTML, etc.
2. json format data calling
The Code is as follows:
$. Ajax ({
Url: "/trundle/RawContentAction. getAjaxContent. act ",
Data: "param1 = 22 ",
DataType: "json", // The dataType here is the returned data format in html, xml, json
Cache: false, // set whether to cache. The default value is true. If you need to perform database operations for each refresh, set it to false.
Success: function (data ){
$ (Data). each (function (te, u ){
Alert (te );
$ ("# Content"). append (u. title +"
");
})
}
})
3. xml format data calling
The Code is as follows:
$. Ajax ({
Url: "/trundle/RawContentAction. getAjaxContent. act ",
Data: "param1 = 22 ",
DataType: "xml", // The dataType here is the returned data format in html, xml, json
Cache: false, // set whether to cache. The default value is true. If you need to perform database operations for each refresh, set it to false.
Success: function (xml ){
$ (Xml). find ("*"). each (function (){
// Process the retrieved content. jquery can use xpath for traversal.
})
}
})