How to wait and delay for 5 seconds for the next lines? When i used setTimeout,but it wont wait
here's my code
<script>
$("#btnSubmit").click(function () {
var lines = $('textarea').val().split('\n');
for (var i = 0; i < lines.length; i++) {
chk(lines[i]);
//wait after get request completed and need to delay for 5 seconds for next lines
}
});
function chk(i) {
$.get("check.php?domain=" + i)
.done(function (data) {
$("#mt > tbody").append(data);
$("#curResult").text(i);
return;
})
.fail(function () {
console.log("error");
return;
})
}
</script>