JQuery ajax json data traversal code, jqueryjson

Source: Internet
Author: User

JQuery ajax json data traversal code, jqueryjson

Let's talk about my requirements first: After an ajax request is made, the following json data is transmitted back in the background.

The specific implementation code is as follows:

JavaScript code

{"Data": [{"id": "1", "name": "select A", "value": "A" },{ "id ": "2", "name": "select B", "value": "B" },{ "id": "3", "name": "select C ", "value": "C"}]}

The preceding json data class is parsed in the success function of jquery.

JavaScript code

$. Ajax ({type: "POST", url: "xxx. do ", dataType:" json ", // specify the return type data: {xxx:" yyy "}, // The parameter success: function (data) {$. each (data, function (index, values) {// parse the Object array corresponding to data $. each (values, function (index2, value) {// traverses the Object array. The value of each Object is stored in value, index2 indicates the first few objects. // process data according to your own logic. alert (value. name + "" + value. value); // TODO: logic}) ;}, error: function () {alert ("system error ");}});

The above is the jQuery ajax json data traversal Code introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.