Possible Duplicate:
I have a nested data structure / JSON, how can access a specific value?
This is my js code for ajax call
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');
}
});
For instance :The UserArr will be like this:
[0] will have userid: 101, username: jack
[1] will have userid: 102, username: jones
I have tried like this but it doesnt seems to work
for (var i = 0; i < UserArr.length; i++) {
User_ID = // i couldn get like UserArr.userid
Name = // i couldn get like UserArr.username
}
Kindly help me out..