How to make Ajax Request

Hi everyone

How to make ajax request…

View




<?php

  echo Html::tag('h4', 'Select Bidding');

  

  echo Html::beginForm('getbidding', 'POST', [

  'onsubmit'=>" $.ajax({

            url: form.attr('action'),   

            type: 'post',

            data: form.serialize(),

            

       });"    

  ]);

  

  echo Html::dropDownList("bidding_group", Yii::$app->request->post()['chit_group'],

  $listData, ['prompt'=>'Select Chit Group', 'style'=>'width:20%;', 'required'=>'required']);

  

  echo "<br>";

?>

    <br>

    <div class="form-group">

         <?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>

    </div>

<?php

 echo  Html::endForm();

?>



Controller


public function actionGetBidding()

{

$orgid= Yii::$app->request->post()['bidding_group'];

$dataProvider = new ActiveDataProvider([

                    'query' => Bidding::find()->where(['organization_id'=>$orgid]),

                ]);

return $this->render('bidding', [

                  'dataProvider' => $dataProvider]);


}

I want controller to return response to same page and response need to be display as GridView…

Any suggestions how to implement it…

Thanks in advance ::) ::)

Hi,

see this tut may be help you.

http://www.yiiframework.com/wiki/772/pjax-on-activeform-and-gridview-yii2/

Thanks a lot… ::) ::)