consolidate getJson fail callbacks to one function

pull/3054/head
Andrew Bauer 2020-09-20 08:41:16 -05:00
parent 95808cfafe
commit 1d1b0e58d2
8 changed files with 25 additions and 77 deletions

View File

@ -393,10 +393,7 @@ if ( currentView != 'none' && currentView != 'login' ) {
$j(".optionhelp").click(function(evt) {
$j.getJSON(thisUrl + '?request=modal&modal=optionhelp&ohndx=' + evt.target.id)
.done(optionhelpModal)
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
});
});
@ -420,7 +417,7 @@ if ( currentView != 'none' && currentView != 'login' ) {
.done(setNavBar)
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
console.log("Response Text: " + jqxhr.responseText.replace(/(<([^>]+)>)/gi, ''));
if ( textStatus != "timeout" ) {
// The idea is that this should only fail due to auth, so reload the page
// which should go to login if it can't stay logged in.
@ -722,10 +719,7 @@ function reminderClickFunction() {
var option = $j(this).data('pdsa-dropdown-val');
$j.getJSON(thisUrl + '?view=version&action=version&option=' + option)
.done(window.location.reload(true)) //Do a full refresh to update ZM_DYN_LAST_VERSION
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
});
}
@ -745,10 +739,7 @@ function enoperm() {
$j('#ENoPerm').modal('hide');
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function getLogoutModal() {
@ -760,10 +751,7 @@ function getLogoutModal() {
$j("body").append(data.html);
}
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function getStateModal() {
@ -777,10 +765,7 @@ function getStateModal() {
$j('#modalState').modal('show');
manageStateModalBtns();
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function manageStateModalBtns() {
@ -845,3 +830,8 @@ function stateStuff(action, runState, newState) {
location.reload();
});
}
function logAjaxFail(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText.replace(/(<([^>]+)>)/gi, '')); // strip any html from the response
}

View File

@ -188,10 +188,7 @@ function initPage() {
$j('#donateForm').submit();
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
// Makes table sortable
@ -217,10 +214,7 @@ function initPage() {
// Manage the Function modal
manageFunctionModal();
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function applySort(event, ui) {

View File

@ -50,10 +50,7 @@ var cueFrames = null; //make cueFrames available even if we don't send another a
function initialAlarmCues(eventId) {
$j.getJSON(thisUrl + '?view=request&request=status&entity=frames&id=' + eventId, setAlarmCues) //get frames data for alarmCues and inserts into html
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function setAlarmCues(data) {

View File

@ -46,10 +46,7 @@ function getDelConfirmModal() {
}
manageDelConfirmModalBtns();
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
// Manage the DELETE CONFIRMATION modal button
@ -68,10 +65,7 @@ function manageDelConfirmModalBtns() {
$j('#eventTable').bootstrapTable('refresh');
window.location.reload(true);
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
});
// Manage the CANCEL modal button
@ -95,10 +89,7 @@ function getEventDetailModal(eid) {
$j('#eventDetailForm').submit();
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function initPage() {
@ -199,10 +190,7 @@ function initPage() {
$j('#eventTable').bootstrapTable('refresh');
window.location.reload(true);
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
});
// Manage the UNARCHIVE button
@ -221,10 +209,7 @@ function initPage() {
$j('#eventTable').bootstrapTable('refresh');
window.location.reload(true);
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
if ( openFilterWindow ) {
//opener.location.reload(true);
@ -259,10 +244,7 @@ function initPage() {
$j('#eventDetailForm').submit();
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
});
// Manage the EXPORT button

View File

@ -95,10 +95,7 @@ function getEventDetailModal(eid) {
$j('#eventDetailForm').submit();
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function initPage() {

View File

@ -422,10 +422,7 @@ function getModal(id) {
}
$j('#'+id+'Modal').modal('show');
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function manageModalBtns(id) {

View File

@ -32,10 +32,7 @@ function detailFormatter(index, row, $detail) {
.done(function(data) {
$detail.html(data.html);
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function initPage() {
var backBtn = $j('#backBtn');

View File

@ -14,10 +14,7 @@ function getServerModal(sid) {
$j('#serverModalForm').submit();
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function enableServerModal() {
@ -48,10 +45,7 @@ function getStorageModal(sid) {
$j('#storageModalForm').submit();
});
})
.fail(function(jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
console.log("Response Text: " + jqxhr.responseText);
});
.fail(logAjaxFail);
}
function enableStorageModal() {