i've been trying loop through 50 pages of json objects find myself getting stuck after first page (30 objects). using code below, able log "total" given each object, information looking for.
page = 1 $.get("http://[url]/json?cat=1&pgnum=" + page, function(data) { (i in data) { console.log(data[i].total) } });
however, unable find way of going next page (page++
) once have printed 30 "totals". offer suggestions point me in right direction?
i attempting go through pages until content on page single empty object, []
.
thank you.
use recursive function.
function printall(){ printfrompage(0) } function printfrompage(page){ $.get("http://[url]/json?cat=1&pgnum=" + page, function(data) { (i in data) { console.log(data[i].total) } if(data.length > 0){ printfrompage(page + 1) } }); }
Comments
Post a Comment