This is code I'm using right now to do AJAX via JQuery:
$.ajax({
type: "POST",
url: linktopage,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$.each(data, function (index, item) {
alert(item.productId);
});
},
error: function (xhr, status, error) {
}
});
where index = d and item = "[{"productId":5284598},{"productId":5790923}]" but alert(item.productId) is undefined, how can i access each productId?
console.log(data)and it is a string instead of an object, then you are not passing the data back from the server correctly.