var j = 0;
var batchSize = 100;
var json_left_to_process = json.length;
while (json_left_to_process != 0) {
var url_param = "";
for (var i = j; i < j+batchSize; i++) {
url_param += json[i].username + ",";
json_left_to_process--;
}
j += batchSize;
if (json_left_to_process < 100) {
batchSize = json_left_to_process;
}
url_param.substring(0, url_param.lastIndexOf(','));
//make ajax request
$.ajax({
type: "POST",
url: "/api/1.0/getFollowers.php",
data: {param: url_param}
)};
}
I don't want to use
url_param += json[i].username + ",";
Instead, I want to say
newArray.push(json[i].username)
and then
url_param = newArray.join(',');
But I also want to process up to 100 elements in the array at a time. How can I do so?
EDIT: Sorry, I meant up to 100 elements, and then up to another 100 elements, and then up to another 100 elements, etc etc until you've processed everything.