$.ajax({
async: false,
type: "POST",
url: url+"module/listing/"+projectId,
data: "ajax=true",
success: function(response) {
$.each(response, function(key, val) {
alert(val.id);
});
}
});
This is my code. Ajax success I am getting JSON response. Response is in array format. And I want to alert the response. But getting error "TypeError: invalid 'in' operand obj"
for JQuery 1.9.1 version.
I got this error after I encoded twice a JSON array. Maybe it will help anybody.
success: function(response) {
response=JSON.parse(response);
$.each(response, function(key, val) {
alert(val.id);
});
}
Use dataType: "json"
to have jQuery parse the response as JSON. It will solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With