I need to make a call to the server and get batches of 50 records back. I need to do this untill I've had all records. Can somebody help out of this
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;
    }
  });
 
    