可能重複值:
I have a nested data structure/JSON, how can access a specific value?如何迭代,並可以在javascript數組包含JSON響應
這是我Ajax調用JS代碼
var UserArr = new Array();
$.ajax({
type: 'POST',
data: postJSONData,
url: 'PrivateSpace.asmx/GetUserDetails',
dataType: 'json',
async: false,
contentType: 'application/json; charset=utf-8',
success: function success(response) {
debugger;
UserArr = response.d;
},
error: function failure(response) {
alert('failed');
}
});
例如:UserArr會是這樣的:
[0] will have userid: 101, username: jack
[1] will have userid: 102, username: jones
我已經試過這樣的,但它似乎犯規工作
for (var i = 0; i < UserArr.length; i++) {
User_ID = // i couldn get like UserArr.userid
Name = // i couldn get like UserArr.username
}
請幫助我..
謝謝你.. It Works .. :) – Xavier