Monday, 19 August 2013

Ajax formula runs stops working after 1 line.

Ajax formula runs stops working after 1 line.

It is very odd. All the code before and including line 29 works. All code
after line 29 doesn't work. I tried lines 30 and 31 on the console and
they worked. I tried adding a simple line of code changing the backgroun
to red before line 29 and it worked. I put the same line after line 29 and
it didn't work.
$('#button-shipping-method').live('click', function() {
$.ajax({
url: 'index.php?route=checkout/shipping_method/validate',
type: 'post',
data: $('#shipping-method input[type=\'radio\']:checked,
#shipping-method textarea'),
dataType: 'json',
beforeSend: function() {
$('#button-shipping-method').attr('disabled', true);
$('#button-shipping-method').after('<span
class="wait">&nbsp;<img
src="catalog/view/theme/default/image/loading.gif" alt=""
/></span>');
},
complete: function() {
$('#button-shipping-method').attr('disabled', false);
$('.wait').remove();
},
success: function(json) {
$('.warning, .error').remove();
if (json['redirect']) {
location = json['redirect'];
} else if (json['error']) {
if (json['error']['warning']) {
$('#shipping-method .checkout-content').prepend('<div
class="warning" style="display: none;">' +
json['error']['warning'] + '<img
src="catalog/view/theme/default/image/close.png"
alt="" class="close" /></div>');
$('.warning').fadeIn('slow');
}
} else {
$.ajax({
url: 'index.php?route=checkout/payment_method',
dataType: 'html',
success: function(html) {
$('#payment-method .checkout-content').html(html);
// LINE 29
$('#shipping-method
.checkout-content').slideUp('slow');
$('#payment-method
.checkout-content').slideDown('slow');
$('#shipping-method .checkout-heading a').remove();
$('#payment-method .checkout-heading a').remove();
$('#shipping-method
.checkout-heading').append('<a><?php echo
$text_modify; ?></a>');
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText +
"\r\n" + xhr.responseText);
}
});
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" +
xhr.responseText);
}
});
});

No comments:

Post a Comment