diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index 7d81275c0..c1cb4b1e7 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -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.
textStatus: '" + textStatus + "'
errorThrown: '" + errorThrown + "'
responseText:
" + 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.
textStatus: '" + textStatus + "'
errorThrown: '" + errorThrown + "'
responseText:
" + 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'; diff --git a/themes/hotel-reservation-theme/js/global.js b/themes/hotel-reservation-theme/js/global.js index d29ce5d2f..2e7dcafd1 100644 --- a/themes/hotel-reservation-theme/js/global.js +++ b/themes/hotel-reservation-theme/js/global.js @@ -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; +}); diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index 7d81275c0..c1cb4b1e7 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -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.
textStatus: '" + textStatus + "'
errorThrown: '" + errorThrown + "'
responseText:
" + 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.
textStatus: '" + textStatus + "'
errorThrown: '" + errorThrown + "'
responseText:
" + 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'; diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index 2baf58348..1ca00333f 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -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'); }