[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • 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
 
NavneetCommented:
Hi!

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

then
alert(json.length)

thanks!
0
 
NavneetCommented:
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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