I have a query about jQuery\'s $.each method. Below is my ajax which is working quite well:
$.ajax({
url:\'js/people-json.js\',
type:\'post\
Sticking with jQuery, the simplest approach is to loop through all items in data.names, up to the last item in the batch, rejecting those items prior to the start of the batch.
var nameObj = {
index: 0,
batchSize: 200
};
function nextNamesBatch() {
$.each(data.names, function(i, data) {
if(i < nameObj.index) return true;//==continue
if(i >= nameObj.index + nameObj.batchSize) return false;//==break
console.log(data);
});
nameObj.index += nameObj.batchSize;
}
Yes, there's an increasing efficiency issue as the batches progress but I believe that, for moderate size arrays, the overhead will be less than that in the alternative jQuery approach, namely to throttle data.names (or a clone of it) prior to $.each(...).