Processing Summary After jquery Ajax obtains data (HTML, XML, JSON)

Source: Internet
Author: User

1. HTML processing is relatively simple and can be output directly.
Generally, you can use $ ("jb51div"). innerhtml, etc.

2. JSON format data calling
CopyCodeThe 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 + "</BR> ");
})
}
})

3. XML format data calling
copy Code 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, // sets whether to cache. The default value is true. To perform database operations every time you need to refresh, set the value to false.
success: function (XML) {
$ (XML ). find ("*"). each (function () {
// process the retrieved content. jquery can use XPath for traversal.
})
}< BR >})

Related Article

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.