0

I have the following code

 $.get('getstatsAccepted' + tickerid, {tickerid: tickerid}, function(data) {
                     alert(data.length);
                }, 'json');

I want to alert the count of rows returned through this method. How to do this?

Nikunj Kumar
  • 306
  • 6
  • 18

1 Answers1

1

'data' represent a values which you return from server. if you need to get count of list or names, you have to return it as a JSON array.

You can use something like this. (I did not test this). See this post https://stackoverflow.com/a/6756305/2345900

$.get('getstatsAccepted' + tickerid, {tickerid: tickerid}, function(data) {

var key, count = 0;
for(key in data.names) {
  if(data.names.hasOwnProperty(key)) {
    count++;
  }
}
    alert(count);
});
Community
  • 1
  • 1
Sajitha Rathnayake
  • 1,688
  • 3
  • 26
  • 47