mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-18 18:02:15 +09:00
Fix regression from #152 when the server returns XML anyway
This commit is contained in:
parent
ba50e81053
commit
f902ea8c6f
1 changed files with 21 additions and 5 deletions
|
|
@ -115,9 +115,23 @@
|
|||
|
||||
// Define the error handler.
|
||||
var errorHandler = function(xhr, textStatus) {
|
||||
|
||||
// If the server has returned XML anyway, convert to JSON and call the success handler.
|
||||
if (textStatus === 'parsererror' && xhr.responseText && xhr.responseText.match(/<response/)) {
|
||||
var xmldata = $.parseXML(xhr.responseText);
|
||||
if (xmldata) {
|
||||
var jsondata = $.parseJSON(xml2json(xmldata, false, false));
|
||||
if (jsondata && jsondata.response) {
|
||||
return successHandler(jsondata.response, textStatus, xhr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hide the waiting message and display an error notice.
|
||||
clearTimeout(wfsr_timeout);
|
||||
waiting_obj.hide().trigger("cancel_confirm");
|
||||
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + xhr.status + " " + xhr.statusText);
|
||||
var error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")";
|
||||
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info);
|
||||
};
|
||||
|
||||
// Send the AJAX request.
|
||||
|
|
@ -190,15 +204,16 @@
|
|||
|
||||
// If there was a success callback, call it.
|
||||
if($.isFunction(callback_success)) {
|
||||
clearTimeout(wfsr_timeout);
|
||||
waiting_obj.hide().trigger("cancel_confirm");
|
||||
callback_success(data);
|
||||
}
|
||||
};
|
||||
|
||||
// Define the error handler.
|
||||
var errorHandler = function(xhr, textStatus) {
|
||||
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + xhr.status + " " + xhr.statusText);
|
||||
clearTimeout(wfsr_timeout);
|
||||
waiting_obj.hide().trigger("cancel_confirm");
|
||||
var error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")";
|
||||
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info);
|
||||
};
|
||||
|
||||
// Send the AJAX request.
|
||||
|
|
@ -260,7 +275,8 @@
|
|||
var errorHandler = function(xhr, textStatus) {
|
||||
clearTimeout(wfsr_timeout);
|
||||
waiting_obj.hide().trigger("cancel_confirm");
|
||||
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + xhr.status + " " + xhr.statusText);
|
||||
var error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")";
|
||||
alert("AJAX communication error while requesting " + params.module + "." + params.act + "\n\n" + error_info);
|
||||
};
|
||||
|
||||
// Send the AJAX request.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue