Reputation: 4200
success: function (result) {
var messages = result;
for(var i=0;i<=messages.length;i++)
jQuery("#responseMessages").jqGrid(
'addRowData',
i+1,
{distance:messages[i].distance,age:messages[i].age,message:messages[i].message}
);
}
So this is my success callback function of an Ajax call to my mvc app. It then loops through the response and enters each row in a JQgrid. However, I'm getting this error on my page:
messages[i] is undefined
even though all the rows are there and it seems to work fine...
Upvotes: 0
Views: 176
Reputation: 185893
Usually, success arguments are strings. I assume that it is a string in your case too. In that case, you cannot perform index lookups [i]
...
Upvotes: 0