Answer the question
In order to leave comments, you need to log in
How to get the actual value of a variable?
The model has a $myVar variable. When a get request is received before a response is received, it is incremented, then passed to the controller and to views.
Added a form with Pjax
<?php Pjax::begin(); ?>
<?= Html::beginForm('statistics', 'get', ['data-pjax' => '']) ?>
<?= Html::input('text', 'ownerId') ?>
<?= Html::submitButton('Отправить', ['class' => 'flat_button secondary']) ?>
<?= Html::endForm() ?>
<?= $myVar ?>
<?php Pjax::end(); ?>
$(document).ready(function() {
$('.loader').hide()
$(document).on('pjax:send', function() {
$('.loader').show()
})
$(document).on('pjax:success', function() {
$('.loader').hide()
})
});
Answer the question
In order to leave comments, you need to log in
How to pass PHP variable to JS variable?
<script>
var myJsVar = <?= $myPhpVar ?>;
</script>
'hidden', $myPhpVar)
= Html::input(Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question