jQuery(document).ready( function(){ $('div.basket-box').click(function() { document.location.href="/shop/basket/"; }); jQuery.ajax({ type: "POST", headers: { 'X-CSRFToken': 'PGEyRHUs1x4iYQj8iLBKPue5qaGfdn2o' }, url: "/shop/basket_check_ajax/", //data: "id=" + item_id + "&quantity=" + quantity, success: function(a){ if (a["count"] != 0) { $('.b-cart').show(); } } }); jQuery('.basket_add').click( function(e){ e.preventDefault(); var item_id = jQuery(this).attr('id'); var quantity = 1; jQuery.ajax({ type: "POST", data: { csrf: 'PGEyRHUs1x4iYQj8iLBKPue5qaGfdn2o', id: item_id, quantity: quantity }, headers: { 'X-CSRFToken': 'PGEyRHUs1x4iYQj8iLBKPue5qaGfdn2o' }, url: "/shop/basket_add_ajax/", //data: "id=" + item_id + "&quantity=" + quantity, success: function(a){ $('.b-cart .title a').html(a["count"]); $('.b-cart .total i').html(a["summ"]); $('.b-cart').fadeIn(4000); } }); }); //jQuery('.basket_add').click( function(){ //var item_id = jQuery(this).attr('id'); //var quantity=jQuery('#forpost :selected').val(); //if (quantity==null) quantity=1; //jQuery.ajax({ //type: "POST", //url: "/shop/basket_add/", //data: "id=" + item_id + "&quantity=" + quantity, //success: function(a){ //jQuery('#basket_add_dialog').dialog({ //modal: true, //resizable: false, //title: 'Товар добавлен', //buttons: [ //{ //text: 'В корзину', //click: function(){ //jQuery(window.location).attr('href', '/shop/basket/'); //} //}, //{ //text: 'Продолжить покупки', //click: function(){ //jQuery(this).dialog("close"); //window.location.reload(); //} //} //] //}); //}, //}); //}); jQuery('.basket_del').click( function(){ var item_id = jQuery(this).attr('id'); jQuery.ajax({ type: "POST", url: "/shop/basket_del/", data: "id=" + item_id, success: function(a){ window.location.reload(); }, }); }); jQuery('.basket_minus').click( function(){ var item_id = jQuery(this).attr('id'); jQuery.ajax({ type: "POST", url: "/shop/basket_minus/", data: "id=" + item_id, success: function(a){ window.location.reload(); }, }); }); jQuery('.basket_plus').click( function(){ var item_id = jQuery(this).attr('id'); jQuery.ajax({ type: "POST", url: "/shop/basket_plus/", data: "id=" + item_id, success: function(a){ window.location.reload(); }, }); }); }); function sendFeedback() { var feedback_form = $('#feedback_form'); var msg = feedback_form.serialize(); $.ajax({ type: 'POST', url: '/feedback', data: msg, success: function(data) { if (data == "OK") { $('#openModal').hide(); alert('Заявка отправлена'); } }, error: function(xhr, str){ alert('Возникла ошибка: ' + xhr.responseCode); } }); }