Interactive table on Yii2 and AJAX



  • I'm trying to make an interactive table in the annex of yii2, which is a data set of bds, where, when applied to the line, the field is changing. truefalse and vice versa in the relevant data field. How do you put this on a simple php and ajax like that, but how do you make it beautiful for yii2? Clearly, we need a processor in the counter-study/action and some kind of stuff. ajax I'd like a good example. Thank you.



  • A small example of interaction:

    Some action:

    public function actionSomeAjax(){
        Yii::$app->response->format = Response::FORMAT_JSON;
        ....
        return \yii\helpers\Json::encode($answer);
    }
    

    Some idea:

    ...
    <?php
    $this->registerJs('
        $(function(){
            $.get("/someController/some-ajax",function(data){
            ...
            })
        });
    ');
    ?>
    

    I mean, the has to get something back.returnYou can just... echo in the counteraller, but the developers don't recommend it. It's also possible to write js code in the presentation to separate it into the file and connect it or through http://www.yiiframework.com/doc-2.0/yii-web-assetbundle.html or again in the submission $this->registerJsFile()


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2