Firefox running infinitely even after condition met in jquery function

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2011-01-04T21:51:29Z Indexed on 2011/01/04 21:53 UTC
Read the original article Hit count: 137

Filed under:
|

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);
            }
        });
    }
});}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery