AjaxSubmit not working?

Hi I have in my formView code like as


$submitAjax = <<<JS




    $('form#{$model->formName()}').on("BeforeSubmit", function () {

var form = $(this);

// return false if form still have some validation errors

if (form.find('.has-error').length) {

return false;

}

// submit form

$.ajax({

url: form.attr('action'),

type: 'post',

data: form.serialize(),

success: function (response) {

 console.log(response)

},

error  : function (e) 

            {

                console.log(e);

            }

});

return false; // Cancel form submitting.

});

JS;

$this->registerJs($submitAjax);

?>

and my controller


public function actionCreate()

    {

        $model = new Client();


        if ($model->load(Yii::$app->request->post())) {

            if ($model->save()) {

                return  json_encode('ok');


            }

            else

            {

                echo 0;

            }

//            return $this->redirect(['view', 'id' => $model->id_client]);

        } else {

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

                'model' => $model,

            ]);

        }

    }

Effect: https://gyazo.com/a9bed2b7f991c2d24522e6cf2c9d8de9

I would like add new item before redirected pageā€¦ Where is fault?