0
Json Object List.
-------------------------
var params = new Object();
params.Id = personId;
params.cls = Class;
$.ajax({
type: "POST",
dataType: "json",
data: $.toJSON(params),
contentType: "application/json",
url: "../OtpWebService.asmx/GetStudentDetails",
alert(response.d);
}
});
The out-put, when i do alert(response.d); is given below.
actually this is an json object returned by a above code from c#.
[
{"Name":"Nthal","Class":3,"SubjectName":"English "},
{"Name":"Mishal","Class":4,"SubjectName":"Grammer"},
{"Name":"Sanjeev","Class":3,"SubjectName":"Social"},
{"Name":"Michal","Class":5,"SubjectName":"Gk"},
]
迭代,如果我嘗試警報(反應);結果將會是 - > [object] [object]。 我如何遍歷這個對象列表中的每個元素,並通過document.write打印..?哪能通過JSON對象列表
這是一個數組。你如何迭代數組? –
[在JavaScript中循環數組]可能的副本(http://stackoverflow.com/questions/3010840/loop-through-array-in-javascript) –
請在您的問題中查找*並考慮是否易於閱讀。你在那裏使用了很多不正確的標記。只需閱讀格式化提示(「提問」頁面就可以在**編輯區旁邊顯示**)。 –