$js = <<<JS
$('form').on('beforeSubmit', function(){
var data = $(this).serialize();
$.ajax({
url: '/order/default/add-order',
type: 'POST',
data: data,
success: function(response){
$('#basket').html(response);
},
error: function(){
alert('Error!');
}
});
return false;
});
JS;
$this->registerJs($js);
<?= Html::a('<i class="glyphicon glyphicon-shopping-cart"></i>', ['/order/default/add-order'], [
'class' => 'btn btn-default pull-right',
'data-toggle' => 'tooltip',
'data-placement' => 'bottom',
'title' => 'Добавить заказ в корзину',
'data' => [
'confirm' => 'Вы уверены?',
'data-method' => 'post',
],
]) ?>
<?= Html::a('<i class="glyphicon glyphicon-trash text-danger"></i>', ['/order/default/delete-order', 'id' => $order->id], [
'data-toggle' => 'tooltip',
'data-placement' => 'bottom',
'title' => 'Удалить заказ из корзины',
'data' => [
'confirm' => 'Вы уверены?',
'data-method' => 'get',
],
]) ?>
<?= Html::a('<i class="glyphicon glyphicon-trash text-danger"></i>', ['/order/default/delete-order', 'id' => $order->id], [
'data-toggle' => 'tooltip',
'data-placement' => 'bottom',
'title' => 'Удалить заказ из корзины',
'data' => [
'confirm' => 'Вы уверены?',
'data-method' => 'get',
'delete-url' => Url::to('/order/default/delete-order');
],
]) ?>
$('form').on('beforeSubmit', function(){
var data = $(this).serialize();
var url = $(selector).attr('data-delete-url');
$.ajax({
url: url,
type: 'POST',
data: data,
success: function(response){
$('#basket').html(response);
},
error: function(){
alert('Error!');
}
});
return false;
});