Last active
November 2, 2016 12:58
-
-
Save t9toqwerty/69bf3ec6dc4b33ad4f22d3e2912f4838 to your computer and use it in GitHub Desktop.
Execute Loop with delay in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$("#submit").on('click', function () { | |
var links = $('#links').val().split(/\n/); | |
var apiCount = 0; | |
var i=0; | |
processNextAjax(); | |
function processNextAjax() { | |
var temp_links = links.slice(i, i + 9); | |
console.log(temp_links); | |
var data = fetchData(temp_links, apiCount); | |
apiCount++; | |
if (i > links.length) { | |
return; | |
} | |
i = i + 9; | |
setTimeout(processNextAjax, 4000); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment