I have a JQuery "POST" method which returns value
Objects: [{"in_approved":0, "out_approved":0},{"in_approved":1, "out_approved":2}]
Ajax method:
$.ajax({
data: {
"start_date" : startDate,
"end_date" : endDate
},
url: "/admin/analytics",
type: 'POST',
dataType: 'json',
success: function(response)
{
// Accessing returned object
},
error : function(request, status, thrownError){
alert("Error");
return;
}
});
Now, to access the returned object I am using
$.each(response.data, function(index,row){
var in_approved = row.in_approved;
alert(in_approved); // just to see if the value is being stored in the variable.
});
But when I do this I get an error:
Uncaught TypeError: Cannot read property 'length' of undefined
Can anyone explain to me what this error means?
Also how to access the values of the returned object?