ajaxing content/calling controller actions

Hi all,

I currently have a dropdown that has an onChange action that loads data into a div. Looks something like this:




<?= $form->field($model, 'item')->dropDownList($items,

		['onchange'=>'$.post( "' . Yii::$app->urlManager->createUrl(['controller/action', 'veids'=>'']).'"+$(this).val(),

		function( data ){

		$( "#content" ).html( data );

		});'

		]

) ?>



The problem with this is that I can only pass one parameter to that controller.

I would like to be able to do it like this:




Yii::$app->urlManager->createUrl(['controller/action', 'param1'=>val1, 'param2'=>val2, 'param3'=>val3])



Where val1, val2 and val3 would be some form field values. Currently I can input some static values but can only get 1 form value with the code that I have and I can’t find a way to fix it.

Also, in a view I’m calling a controller action to load data into it and I’m doing it through javascript document.ready like this:




$js = "

		$( document ).ready(function() {

    		$.post('". Yii::$app->urlManager->createUrl(['controller/action', 'param1'=>$model->param1, 'readonly'=>'true', 'id'=>$model->id]) ."',

			function( data ){

	    				$( \"#content\" ).html( data );

	    	});

		});

		

		";

    $this->registerJs($js);



I was wondering if there is a better way to do this too…

Thank you!