Show no internet error if operation can not be completed due to network issue

This commit is contained in:
Abhishek Kumar
2023-08-25 13:04:49 +05:30
parent ccace94c38
commit cc2cc97356
5 changed files with 125 additions and 94 deletions

View File

@@ -478,23 +478,27 @@ var ajaxCart = {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
if (XMLHttpRequest.readyState == 0) {
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;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
}
}
});
},
@@ -612,23 +616,27 @@ var ajaxCart = {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
if (XMLHttpRequest.readyState == 0) {
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;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
}
}
});
},
@@ -675,19 +683,23 @@ var ajaxCart = {
deleteProductFromSummary(idProduct + '_' + idCombination + '_' + customizationId + '_' + idAddressDelivery);
}*/
},
error: function() {
var error = 'ERROR: unable to delete the product';
if (!!$.prototype.fancybox) {
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: error
}], {
padding: 0
});
} else
alert(error);
error: function(jqXHR) {
if (jqXHR.readyState == 0) {
showErrorMessage(no_internet_txt);
} else {
var error = 'ERROR: unable to delete the product';
if (!!$.prototype.fancybox) {
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: error
}], {
padding: 0
});
} else
alert(error);
}
}
});
},

View File

@@ -438,6 +438,7 @@
{addJsDefL name=duration_txt}{l s='Duration' mod='blockcart' js=1}{/addJsDefL}
{addJsDefL name=capacity_txt}{l s='Capacity' mod='blockcart' js=1}{/addJsDefL}
{addJsDefL name=remove_rm_title}{l s='Remove this room from my cart' mod='blockcart' js=1}{/addJsDefL}
{addJsDefL name=no_internet_txt}{l s='No internet. Please try later.' mod='blockcart' js=1}{/addJsDefL}
{addJsDef rm_avail_process_lnk = $link->getModuleLink('blockcart', 'checkroomavailabilityajaxprocess')}
{addJsDef pagename = $current_page}

View File

@@ -478,23 +478,27 @@ var ajaxCart = {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
if (XMLHttpRequest.readyState == 0) {
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;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
}
}
});
},
@@ -612,23 +616,27 @@ var ajaxCart = {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var error = "Impossible to add the room to the cart.<br/>textStatus: '" + textStatus + "'<br/>errorThrown: '" + errorThrown + "'<br/>responseText:<br/>" + XMLHttpRequest.responseText;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
if (XMLHttpRequest.readyState == 0) {
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;
if (!!$.prototype.fancybox)
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: '<p class="fancybox-error">' + error + '</p>'
}], {
padding: 0
});
else
alert(error);
//reactive the button when adding has finished
if (addedFromProductPage)
$('#add_to_cart button').removeProp('disabled').removeClass('disabled');
else
$(callerElement).removeProp('disabled');
}
}
});
},
@@ -675,19 +683,23 @@ var ajaxCart = {
deleteProductFromSummary(idProduct + '_' + idCombination + '_' + customizationId + '_' + idAddressDelivery);
}*/
},
error: function() {
var error = 'ERROR: unable to delete the product';
if (!!$.prototype.fancybox) {
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: error
}], {
padding: 0
});
} else
alert(error);
error: function(jqXHR) {
if (jqXHR.readyState == 0) {
showErrorMessage(no_internet_txt);
} else {
var error = 'ERROR: unable to delete the product';
if (!!$.prototype.fancybox) {
$.fancybox.open([{
type: 'inline',
autoScale: true,
minHeight: 30,
content: error
}], {
padding: 0
});
} else
alert(error);
}
}
});
},

View File

@@ -1458,6 +1458,11 @@ var BookingForm = {
BookingForm.init();
}
},
error: function(jqXHR) {
if (jqXHR.readyState == 0) {
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');

View File

@@ -438,6 +438,7 @@
{addJsDefL name=duration_txt}{l s='Duration' mod='blockcart' js=1}{/addJsDefL}
{addJsDefL name=capacity_txt}{l s='Capacity' mod='blockcart' js=1}{/addJsDefL}
{addJsDefL name=remove_rm_title}{l s='Remove this room from my cart' mod='blockcart' js=1}{/addJsDefL}
{addJsDefL name=no_internet_txt}{l s='No internet. Please try later.' mod='blockcart' js=1}{/addJsDefL}
{addJsDef rm_avail_process_lnk = $link->getModuleLink('blockcart', 'checkroomavailabilityajaxprocess')}
{addJsDef pagename = $current_page}