Answer the question
In order to leave comments, you need to log in
How to call a table using ajax in yii2?
Hello! Never worked with ajax before. It is necessary for me at in a view at pushing the button to cause the table.
To do this, I added a table and a button to the view
<?= GridView::widget([
'dataProvider' => $dataProvider2,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'description',
'image',
'creation_date',
'date_of_change',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
<?= Html::a('Показать героев', ['/kniga1/Hero'], ['class'=>'btn btn-primary']) ?>
public function actionHero (){
}
Answer the question
In order to leave comments, you need to log in
Send an ajax request when clicking on the button, generate html on the server, get it in js in the response and paste it in the right place.
But you can generate immediately, hide and show on click.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question