Some file is creating in backend (up to 1min). I wrote a function to check if file is ready
function check_for_file() {
$.ajax({
url: '/check/', // check if file exists
success: function(data) {
location.replace('/hello/'); // redirect to download
return true;
},
failure: function(data) {
alert('Got an error');
}
});
return false
}
a = check_for_file();
}
// a= false
// while (a == false) {
// a = check_for_file();
// }
console.log(a);
This works fine. But I need to make a loop which will check while file is not ready. What should I do?
!!!!!!!! Look at first comment for an answer