Use 'online' and 'offline' events to display error messages
This commit is contained in:
@@ -482,7 +482,7 @@ var ajaxCart = {
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (XMLHttpRequest.readyState == 0) {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
} else {
|
||||
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
|
||||
@@ -620,7 +620,7 @@ var ajaxCart = {
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (XMLHttpRequest.readyState == 0) {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
} else {
|
||||
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
|
||||
@@ -694,8 +694,8 @@ var ajaxCart = {
|
||||
deleteProductFromSummary(idProduct + '_' + idCombination + '_' + customizationId + '_' + idAddressDelivery);
|
||||
}*/
|
||||
},
|
||||
error: function(jqXHR) {
|
||||
if (jqXHR.readyState == 0) {
|
||||
error: function() {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
} else {
|
||||
var error = 'ERROR: unable to delete the product';
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
//global variables
|
||||
var responsiveflag = false;
|
||||
var onlineFlag = true;
|
||||
|
||||
|
||||
|
||||
@@ -494,3 +495,11 @@ function showErrorMessage(msg) {
|
||||
function showNoticeMessage(msg) {
|
||||
$.growl.notice({ title: "", message:msg});
|
||||
}
|
||||
|
||||
window.addEventListener('online', function () {
|
||||
onlineFlag = true;
|
||||
});
|
||||
|
||||
window.addEventListener('offline', function () {
|
||||
onlineFlag = false;
|
||||
});
|
||||
|
||||
@@ -482,7 +482,7 @@ var ajaxCart = {
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (XMLHttpRequest.readyState == 0) {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
} else {
|
||||
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
|
||||
@@ -620,7 +620,7 @@ var ajaxCart = {
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (XMLHttpRequest.readyState == 0) {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
} else {
|
||||
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
|
||||
@@ -694,8 +694,8 @@ var ajaxCart = {
|
||||
deleteProductFromSummary(idProduct + '_' + idCombination + '_' + customizationId + '_' + idAddressDelivery);
|
||||
}*/
|
||||
},
|
||||
error: function(jqXHR) {
|
||||
if (jqXHR.readyState == 0) {
|
||||
error: function() {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
} else {
|
||||
var error = 'ERROR: unable to delete the product';
|
||||
|
||||
@@ -1466,10 +1466,12 @@ var BookingForm = {
|
||||
}
|
||||
}
|
||||
},
|
||||
complete: function(jqXHR, textStatus) {
|
||||
if (textStatus == 'error') {
|
||||
error: function() {
|
||||
if (!onlineFlag) {
|
||||
showErrorMessage(no_internet_txt);
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
$('.book_now_submit').prop('disabled', false).find('span:not(#booking_action_loader)').show();
|
||||
$('#booking_action_block').find('#booking_action_loader').removeClass('active');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user