Firefox running infinitely even after condition met in jquery function
- by Kyle
The following function is called with
setTimeout(function () { get_progress(fileID,fileName)},8000);
upon a form submit. The purpose of the function is to get read_file.php to read a txt file that stores the file upload status from a form (in percentage).
Upon reaching 80%, my Firefox seems to run infinitely even when HEAD returns an error. Am I have too many recursions or have I used a wrong condition that's causing get_progress to run repeatedly even when filename does not exist in the folder ?
function get_progress( fileID, filename) {
$.ajax({
url: filename,
type: 'HEAD',
success: function() {
$.ajax({
type: 'POST',
url: 'read_file.php',
data: 'filename=' +filename,
success: function(html) {
document.getElementById(fileID).innerHTML = html + ' <img src="images/loading.gif" />'
setInterval(function() {get_progress(fileID,filename)},4000);
}
});
}
});}