我需要调用服务器并获取50个记录的批次。我需要这样做,直到我有所有记录。有人可以帮忙吗
var stillRecordsAvailable = true;
var start = 1;
while (stillRecordsAvailable) {
// get the next batch of records
$.ajax({
url: '/getData?start='+start+'&recordLimit=50',
type: 'GET',
success: function(data) {
if(data.records == 0){
stillRecordsAvailable = false;
}
else{
start += 50;
// do something
}
},
error: function(data) {
// nothing left to do
stillRecordsAvailable = false;
}
});