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!