Reputation: 71
How can I use Pjax
in Yii 2
with POST request?
I tried to do it like that but page restarts anyway:
<?php Pjax::begin(['id' => 'some-id', 'clientOptions' => ['method' => 'POST']]);?>
...
some content
...
<?=Html::a('', ['cart/cart'],
['class'=>'close1',
'data' => [
'method' => 'post',
'params' => [
'idCartToDelete' => $product->idCart,
],
]
]
)
?>
...
some content
...
<?php Pjax::end(); ?>
Upvotes: 3
Views: 3107
Reputation: 7103
You're close to solving your issue. To your Html::a
parameters add:
'data-pjax' => 0,
And you will have a link that does not redirect to another page.
Upvotes: 2