Page 2 of 2

Count results from JSON request

Posted: Mon Oct 06, 2014 4:45 pm
by Kateryna Grynko

Welcome Robert :)


Count results from JSON request

Posted: Mon Oct 06, 2014 7:25 pm
by RobertJay

In now trying to expand my new knowledge into the Complete event (as opposed to the Success event), I'm trying to use both the jqXHR and textStatus params -- as well as e.g. jqXHR.responseText -- in different ways to get a count as well as the value of a specific record index. Is there a way of doing it as easily as the data structure does it for the Success event. Thanks very much.


Count results from JSON request

Posted: Mon Oct 06, 2014 8:59 pm
by Kateryna Grynko

Dear Robert,

Let's output jqXHR to console to see what is returned.


Count results from JSON request

Posted: Mon Oct 06, 2014 9:14 pm
by RobertJay

Thank you so much. Here it is: http://screencast.com/t/A0kpbP62


Count results from JSON request

Posted: Tue Oct 07, 2014 3:06 am
by Yurii Orishchuk

Hi Robert,

here is code to get "data" object in "complete" event like in success event.

Note: it works only with JSON response.

pre

var data = JSON.parse(jqXHR.responseText);

console.log(data.length);

/pre

Regards.


Count results from JSON request

Posted: Tue Oct 07, 2014 2:37 pm
by RobertJay

Perfect Yurii - thanks a million.