How to get the current value of the variable?

In the model there is a variable $myVar. When you get request to get response it is increased, is then transmitted to the controller and in views.
Added a form with Pjax
<?php Pjax::begin(); ?>
 <?= Html::beginForm('statistics', 'get', ['data-pjax' =--> "]) ?>
 <?= Html::input('text', 'ownerId') ?>
 <?= Html::submitButton('Send', ['class' =--> 'flat_button secondary']) ?>
 <?= Html::endForm() ?>
 <?= $myVar ?>
 <?php Pjax::end(); ?>

Added to show the loader until the request is Pjax.
In js file:
$(document).ready(function() {

 $(document).on('pjax:send', function() {

 $(document).on('pjax:success', function() {

The question how to pass in View, until there is an ajax get request the current value of variable myVar?
June 26th 19 at 14:02
1 answer
June 26th 19 at 14:04
How to pass PHP variable into JS variable?
the <script>
var myJsVar = <?= $myPhpVar ?>;

How to pass PHP variable directly in the ajax request?
<?= Html::input('hidden', $myPhpVar) ?>
Need from the model to pass to Views - sofia_Whi commented on June 26th 19 at 14:07
<?= $model--->attribute name ?> - Jerad_Padbe commented on June 26th 19 at 14:10

Find more questions by tags YiiPHP