I have a function to upload a file using Ajax. It works fine in a normal situation. Now I'm trying to differentiate between a "Network error" and a "File does not exist error". The code looks basically like this:
$.ajax({
type: 'PUT',
url: upload_url,
processData: false,
data: selected_file,
error: function(xhr, status, error) {
logger.error("Error uploading file");
}
});
This is what I've discovered so far:
In both cases, the parameters for the Ajax error function are very similar: xhr.status
is 0, status
is "error" and error
is "".
I can clearly see different error codes in the Chrome console: net::ERR_INTERNET_DISCONNECTED
and net::err_file_not_found
but I can't/don't know how to find this codes from the Ajax error function.