I'm working with pages like http://musicbrainz.org/release/72cf3c87-d97d-49cc-8781-661ad3580091/cover-art-uploader?id=17477511090 . This is generally an iframe's source, but I'm using it outside of the iframe, in a userscript. I've been testing submitting the form on that page with javascript, but I do not want the redirect after submission.
Here's the js I've been running from the console:
jQuery(document.forms[0]).submit(function (e) {
e.preventDefault();
alert('foo');
return false;
})[0].submit();
From everything I know, it ought to submit, then the event handler kick in to stop the redirect. However, when the server gives anything other than a 200 status, such as 500 Internal Server Error, I still get the redirect.
So 1) How can I detect the error, and its status code, and 2) how can I prevent the redirect, even when the result is an error?