retry once

v1.18.x
barisusakli 9 years ago
parent 09b93ac6ff
commit e11140b7ef

@ -4,13 +4,14 @@ var ajaxify = ajaxify || {};
$(document).ready(function() { $(document).ready(function() {
/*global app, templates, utils, socket, config, RELATIVE_PATH*/ /*global app, templates, socket, config, RELATIVE_PATH*/
var location = document.location || window.location, var location = document.location || window.location;
rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : ''), var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
apiXHR = null, var apiXHR = null;
translator; var translator;
var retry = true;
// Dumb hack to fool ajaxify into thinking translator is still a global // Dumb hack to fool ajaxify into thinking translator is still a global
// When ajaxify is migrated to a require.js module, then this can be merged into the "define" call // When ajaxify is migrated to a require.js module, then this can be merged into the "define" call
@ -63,7 +64,7 @@ $(document).ready(function() {
if (err) { if (err) {
return onAjaxError(err, url, callback, quiet); return onAjaxError(err, url, callback, quiet);
} }
retry = true;
app.template = data.template.name; app.template = data.template.name;
require(['translator'], function(translator) { require(['translator'], function(translator) {
@ -107,12 +108,16 @@ $(document).ready(function() {
}; };
function onAjaxError(err, url, callback, quiet) { function onAjaxError(err, url, callback, quiet) {
var data = err.data, var data = err.data;
textStatus = err.textStatus; var textStatus = err.textStatus;
if (data) { if (data) {
var status = parseInt(data.status, 10); var status = parseInt(data.status, 10);
if (status === 403 || status === 404 || status === 500 || status === 502 || status === 503) { if (status === 403 || status === 404 || status === 500 || status === 502 || status === 503) {
if (status === 502 && retry) {
retry = false;
return ajaxify.go(url, callback, quiet);
}
if (status === 502) { if (status === 502) {
status = 500; status = 500;
} }

Loading…
Cancel
Save