I am trying to implement error handling for blueimp jQuery-File-Upload. It is easy to implement for errors that I can catch on the server and wrap them in a JSON object. But what if there is a PHP error on the server and the message is displayed as a standard PHP message? I tried to process it with a rollback:
jQuery('#fileupload').fileupload({
fail: function (ev, data) {
if (data.jqXHR) {
alert('Server-error:\n\n' + data.jqXHR.responseText);
}
},
otherOptions
});
It works, but the callback also starts if I press the cancel button to delete the image. So I added if when data.jqXHR will be different between server error and clicking cancel button. But then, if the cancel button is pressed, the image is no longer removed from the list.
Any idea how to implement such error handling for unexpected server errors?
Thanks Ben