You can do it as follows:
$url = \yii\helpers\Url::to([
'public/getlist',
'param1' => '01',
'param2' => '02',
'param3' => '03'
]);
$js = <<< JS
$('.list-link').click(function(){
$.ajax({
url: $url,
dataType: "json",
success: function(data) {
$(".well").html(data.id);
}
})
});
JS;
$this->registerJs($js);
Of course, you can also make the number of parameters dynamic, since it is just an array that is passed to Url :: to () .
Official information on the Heredoc syntax used (which allows the use of variables) can be found here .
source
share