[ticket/11279] Clearer AJAX errors

Display clearer AJAX errors rather than generic error

PHPBB3-11279
This commit is contained in:
Vjacheslav Trushkin 2013-05-20 21:35:51 +03:00
parent 778658f787
commit a9c9448ebb
4 changed files with 19 additions and 4 deletions

View file

@ -18,7 +18,7 @@
{DEBUG_OUTPUT} {DEBUG_OUTPUT}
<!-- ENDIF --> <!-- ENDIF -->
<div id="darkenwrapper" data-ajax-error-title="{L_AJAX_ERROR_TITLE}" data-ajax-error-text="{L_AJAX_ERROR_TEXT}"> <div id="darkenwrapper" data-ajax-error-title="{L_AJAX_ERROR_TITLE}" data-ajax-error-text="{L_AJAX_ERROR_TEXT}" data-ajax-error-text-abort="{L_AJAX_ERROR_TEXT_ABORT}" data-ajax-error-text-timeout="{L_AJAX_ERROR_TEXT_TIMEOUT}" data-ajax-error-text-parsererror="{L_AJAX_ERROR_TEXT_PARSERERROR}">
<div id="darken">&nbsp;</div> <div id="darken">&nbsp;</div>
<div class="jalert" id="loadingalert"><h3>{L_LOADING}</h3><p>{L_PLEASE_WAIT}</p></div> <div class="jalert" id="loadingalert"><h3>{L_LOADING}</h3><p>{L_PLEASE_WAIT}</p></div>
</div> </div>

View file

@ -252,9 +252,21 @@ phpbb.ajaxify = function(options) {
return; return;
} }
function errorHandler() { /**
* Handler for AJAX errors
*/
function errorHandler(jqXHR, textStatus, errorThrown) {
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); var errorText = false;
if (typeof errorThrown === 'string' && errorThrown.length > 0) {
errorText = errorThrown;
}
else {
errorText = dark.attr('data-ajax-error-text-' + textStatus);
if (typeof errorText !== 'string' || !errorText.length)
errorText = dark.attr('data-ajax-error-text');
}
phpbb.alert(dark.attr('data-ajax-error-title'), errorText);
} }
/** /**

View file

@ -70,6 +70,9 @@ $lang = array_merge($lang, array(
'AIM' => 'AIM', 'AIM' => 'AIM',
'AJAX_ERROR_TITLE' => 'AJAX error', 'AJAX_ERROR_TITLE' => 'AJAX error',
'AJAX_ERROR_TEXT' => 'Something went wrong when processing your request.', 'AJAX_ERROR_TEXT' => 'Something went wrong when processing your request.',
'AJAX_ERROR_TEXT_ABORT' => 'User aborted request.',
'AJAX_ERROR_TEXT_TIMEOUT' => 'Your request timed out; please try again.',
'AJAX_ERROR_TEXT_PARSERERROR' => 'Something went wrong with the request and the server returned an invalid reply.',
'ALLOWED' => 'Allowed', 'ALLOWED' => 'Allowed',
'ALL_FILES' => 'All files', 'ALL_FILES' => 'All files',
'ALL_FORUMS' => 'All forums', 'ALL_FORUMS' => 'All forums',

View file

@ -29,7 +29,7 @@
<!-- IF U_ACP --><br /><strong><a href="{U_ACP}">{L_ACP}</a></strong><!-- ENDIF --> <!-- IF U_ACP --><br /><strong><a href="{U_ACP}">{L_ACP}</a></strong><!-- ENDIF -->
</div> </div>
<div id="darkenwrapper" data-ajax-error-title="{L_AJAX_ERROR_TITLE}" data-ajax-error-text="{L_AJAX_ERROR_TEXT}"> <div id="darkenwrapper" data-ajax-error-title="{L_AJAX_ERROR_TITLE}" data-ajax-error-text="{L_AJAX_ERROR_TEXT}" data-ajax-error-text-abort="{L_AJAX_ERROR_TEXT_ABORT}" data-ajax-error-text-timeout="{L_AJAX_ERROR_TEXT_TIMEOUT}" data-ajax-error-text-parsererror="{L_AJAX_ERROR_TEXT_PARSERERROR}">
<div id="darken">&nbsp;</div> <div id="darken">&nbsp;</div>
<div class="phpbb_alert" id="loadingalert"><h3>{L_LOADING}</h3><p>{L_PLEASE_WAIT}</p></div> <div class="phpbb_alert" id="loadingalert"><h3>{L_LOADING}</h3><p>{L_PLEASE_WAIT}</p></div>
</div> </div>