I want to check for a file with jQuery/Ajax.
I'm generating a file and this can take 30 - 90 seconds.
I want jQuery/Ajax to check every X (e.g. 5) seconds, if the file already exists (has been generated).
How can I do this?
Additionally I want to know if the file has really been generated completly and so I want to check for unique access (or if an error occurs, because the document is getting written).
Is this possible?
I've found the following code snippet to check for files, but it seems to always send an "OK".
$.ajax({
url:'http://www.example.com/somefile.ext',
type:'HEAD',
error:
function(){
//do something depressing
},
success:
function(){
//do something cheerful :)
}
});
source: http://www.ambitionlab.com/how-to-check-if-a-file-exists-using-jquery-2010-01-06