We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 7d202e9c authored by Brion Vibber's avatar Brion Vibber

Detect and show AJAX errors on FormXHR submission handling.

Previously we threw away errore reported by the actual AJAX submission and only used whatever error the browser reported to us; this didn't help if we reached the server ok but had a problem there.
We now extract the #error if given and use that in the alert().
Also should now show 'Unknown error' instead of a crappy generic 'something died in jQuery' when we get a 200 response but bogus return data.
parent 2bad1d0c
......@@ -253,16 +253,34 @@ var SN = { // StatusNet
.attr(SN.C.S.Disabled, SN.C.S.Disabled);
},
error: function (xhr, textStatus, errorThrown) {
alert(errorThrown || textStatus);
// If the server end reported an error from StatusNet,
// find it -- otherwise we'll see what was reported
// from the browser.
var errorReported = null;
if (xhr.responseXML) {
errorReported = $('#error', xhr.responseXML).text();
}
alert(errorReported || errorThrown || textStatus);
// Restore the form to original state.
// Hopefully. :D
form
.removeClass(SN.C.S.Processing)
.find('.submit')
.removeClass(SN.C.S.Disabled)
.removeAttr(SN.C.S.Disabled);
},
success: function(data, textStatus) {
if (typeof($('form', data)[0]) != 'undefined') {
form_new = document._importNode($('form', data)[0], true);
form.replaceWith(form_new);
}
else {
else if (typeof($('p', data)[0]) != 'undefined') {
form.replaceWith(document._importNode($('p', data)[0], true));
}
else {
alert('Unknown error.');
}
}
});
},
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment