I have this JS loop:
for (var i = 0; i < jsArr.length; ++i) {
$.post("checkdata.php", { names: jsArr[i], platforms: "1" })
.done(function(data) {
eval(data);
});
}
data is some jQuery CSS manipulation. I have a loading image that is under the "loadingImg" div class which is display on page load. checkdata.php checks the names against the API https://www.xboxleaders.com/
What's the best way to accomplish $('#loadingImg').hide(); (to hide the image) after the loop and the jQuery .done processes complete?
I have thought about adding it after the loop, but that does not guarantee checkdata has finished.
.hideas part of your.donecallback. You'll need to track whether you're on the last iteration. Of course, if you can send ll the data at once (thanks @koala_dev) then there are fewer calls, faster response, and no tracking to considernamesArr : jsArrand send data for all images not only for one.eval()