Reputation: 660
The following is the format of the JQGrid:
{
"total":25,
"page":1
"records":107,
"userdata": {"foo": "bar"},
"rows": [...]
}
I am looking for the JQuery code that will help me to parse the data that is returned into my rows
. I have used the following code after getting the ajax success
response and:
$.each(data, function (index, element) {
if (index == 'rows') {
$.each(element, function (index1, element1) {
alert(element1 + index1)
});
}
});
But, in my inner $.each()
i am not able to fetch the values of each element, can anyone help me to fetch all the element's data.
Upvotes: 0
Views: 593
Reputation: 74738
Don't know why you have a if check for 'rows'
instead you can check directly like this:
$.each(data.rows, function (index, element){
alert(element + index);
});
As per your latest comment:
main concern here is to pick the first value from the string
So for this you can have a check for the index 0
like below:
$.each(data.rows, function (index, element){
if(index == 0){
alert(element + index);
}
});
so here alert will come only for index 0
A demo fiddle about it..
Upvotes: 1