• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Count JSON AJAX returned results

Hi,

I'm very new to using webservices with ajax, how can i get the total returned results from an ajax call?

I have attached the code in question below, which returns results successfully.

thanks,

Sam
$.ajax({
                type: "POST",
                datatype: "json",
                url: "../SearchSuggest/SearchSuggestLoc.aspx?pKeywords=" + Keywords,
                success: function () { me.RequestSuccess(); },
                //error: function (jqXHR, textStatus, errorThown) { alert( errorThown) },
                complete: function (data) {
                    me.RecieveData(data); 
                
                }
                
            });

Open in new window

0
OTM
Asked:
OTM
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
without seeing the json, it's not possible to answer.

try :
var total = data.length;
alert(total);

or :
var total = data.total;
alert(total);

or :
var total = data.count;
alert(total);
0
 
NavneetSoftware EngineerCommented:
Hi!

if you have say
var json = [ {a:b, c:d}, {e:f, g:h, ...}, {..}, ... ]

then
alert(json.length)

thanks!
0
 
NavneetSoftware EngineerCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now