Показать сообщение отдельно
  #1 (permalink)  
Старый 07.03.2021, 22:01
Интересующийся
Отправить личное сообщение для MaJIon Посмотреть профиль Найти все сообщения от MaJIon
 
Регистрация: 12.02.2021
Сообщений: 10

Ошибка синтаксиса
Здравствуйте, подскажите пожалуйста, что тут не правильно?
При смене dataType: 'html', на dataType: 'json', пишет ошибка синтаксиса


'updateCart': function(product_id, cart_id, flag) {	

			var input = $('input[name=\'' + cart_id + '\']');	
			
			if(flag == '+') {
				input.val(parseFloat(input.val())+1);
			}
			
			if(flag == '-') {
				input.val(parseFloat(input.val())-1);
			}
			
			if (quantity == '') return;
			
			var quantity = parseFloat(input.val());
			
			$.ajax({
				url: 'index.php?route=checkout/cart/edit',
				type: 'post',
				data: 'quantity['+cart_id+']=' + (typeof(quantity) != 'undefined' ? quantity : 1),
				dataType: 'json',
				beforeSend: function() {
					$('button#cart_popup').button('loading');
				},
				complete: function() {
					$('button#cart_popup').button('reset');
				},
				success: function(json) {
	 
					if (quantity == 0 ) {
						$('.cartsanimated .cart-icon').html('');
					} else {
						setTimeout(function () {
							$('.cartsanimated .cart-icon').html('<span id="totalproduct">' + json['total'] + '</span>');
						}, 100);
					}
					
					$('#cartModdals ul').load('index.php?route=common/cart/info ul li');
					
					if (!quantity) {
						restore_button(product_id);
					}
				},
				error: function(xhr, ajaxOptions, thrownError) {
					alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
				}
			});
		},
Ответить с цитированием