$ (function () {
var tbody = "";
------------traverse the object. Each use-------------
Object syntax JSON data format (when the server-side callback Object Data format is JSON data format, must ensure that the JSON format requirements, the callback object must use the Eval function to convert (otherwise will not get object). This article does not give a detailed description of the server-side callback data issues, we will directly customize the object)
var obj = [{"Name": "Item Navy", "Password": "123456"}];
$ ("#result"). HTML ("------------traversal object. Each use-------------");
alert (obj); It's an object element.
The following uses each to traverse
$.each (obj, function (n, value) {
Alert (n + ' + value);
var trs = "";
TRS + = "<tr><td>" + value.name + "</td> <td>" + Value.password + "</td></tr>";
Tbody + = TRS;
});
$ ("#project"). Append (tbody);
});
jquery traversal parsing JSON object 1:
var json = [{dd: ' SB ', AA: ' Dongdong ', RE1:123},{CCCC: ' DD ', LK: ' 1QW '}];
for (Var i=0,l=json.length;i<l;i++) {
for (var key in Json[i]) {
Alert (key+ ': ' +json[i][key]);
}
}
jquery Traversal parsing JSON object 2
The following JSON objects are available:
var obj ={"name": "Feng Juan", "Password": "123456″," "Department": "Technical department", "Sex": "female", "old": 30};
Traversal method:
For (var p in obj) {
str = str+obj[p]+ ', ';
return str;
}
Article turned from: http://blog.csdn.net/happy664618843/article/details/7934221
"Go" jquery Traversal JSON array method