Skip to content

Instantly share code, notes, and snippets.

@amiskov
Last active January 29, 2016 12:02
Show Gist options
  • Save amiskov/591ca51f417687bf89b9 to your computer and use it in GitHub Desktop.
Save amiskov/591ca51f417687bf89b9 to your computer and use it in GitHub Desktop.
var ajax = {
success: function (data) {
if (!data) {
alert('Ошибка, сервера.');
return;
}
if (data.status == 'success') {
var shippingMethods = 'shipping_methods',
paymentMethods = 'payment_methods',
$shippingStep = $('#checkout-step-shipping_method'),
$paymentStep = $('#checkout-step-payment'),
$reviewTable = $('#checkout-review-load'),
$couponBlock = $('#couponBlock');
if (data.content == undefined) {
alert('Контент не пришел');
return;
}
if (data.content[shippingMethods]) {
$shippingStep.html(data.content[shippingMethods]);
checkoutObj.initShippingForm();
}
if (data.content[paymentMethods]) {
$paymentStep.html(data.content[paymentMethods]);
checkoutObj.initPaymentMethods();
}
if (data.content.cart) {
$reviewTable.html(data.content.cart);
}
if (data.content.coupon) {
$couponBlock.replaceWith(data.content.coupon);
coupon.init(checkoutObj);
}
} else if ((data.status === 'error') && data.message) {
$info.html(data.message).addClass('error');
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment