Hi guys!
I need your help, please.
I have this code js, where there are a ajax variable “idpadre” that i need to pass to variable php “variablePHP”, but i can’t:
$(document).ready(function() {
$("#idElement").change(function(event)
{
var idpadre = "value";
$("#pidhijo").load('<?= Url::to(['combobox', 'variablePHP' => "idpadre"]) ?>');
});
});
My code php is:
<?php
$variablePHP= $_GET['variablePHP'];
echo $variablePHP;
?>
An important point to consider, is that this code work!, if i send in the previous url one constant, for example “1” ($("#pidhijo").load(’<?= Url::to([‘combobox’, ‘idpadre’ => 1]) ?>’), but i need send a variable.
In other forum, i find this for yii 1:
$this->registerJs(
'jQuery(document).ready(function($){
$(".member").on("change",function(){
var id = $(this).attr("id");
// alert(id);
var n = $(this).val();
// alert(n);
$.post("'.\Yii::$app->getUrlManager()->createUrl(['death/stl_set_relation']).'?id="+id+"&relation="+n)
});
});'
);
But i don’t know how suit to my need, in yii2 by method get
appreciate any help
Regards!