I am using Angular, but same thing happens with a normal jQuery Ajax request, to get data.
Data structure is:
{
"providers":
{
"complete":[1,2,3],
"inProgress":[4,5,6]
},
"results":
[
{"thing":{"id":"1234"},"somethingelse":null},
{"thing":{"id":"5678"},"somethingelse":null}
]
}
The Ajax request looks like this:
$.ajax({
dataType: 'jsonp',
headers: {'cache-control': 'no-cache'},
url: $resultsURL
}).done(function(data) {
and the Angular request:
$http.jsonp($resultsURL)
.success(function(data, status){
Now, kind of hard to explain without a demo and sadly I can't expose any of the api endpoints, but the above works fine, as expected and tells me I have two results.
Now the real issue, I can append a partials request to the url and get back a smaller data set, with an offset etc, if I try console.log(data.results) I get an empty []. If I try data.results.length, it returns 0.
Appreciate that might not make much sense, so I guess the first thing to solve is why the ajax might return the length of data.results as zero?
Have I missed something massively obvious?
Cheers
Turns out I was hitting the service too quickly so it thought it was empty initially.