convert javascript in yii1 to yii2

function addcartajax(id,OrgName)

	 {


		


		 var a="<?php echo Yii::app()->createUrl( 'product/cart/ac/add') ?>/pid/"+id+"/org/"+OrgName;


		 $.get(a,function(data,status){


					alert(data);


				});


		 


		}	

here in second line of the code i have used yii1 for calling a action method. i would like to know how to convert it into coresponding code in yii2. (especially how to pass parameters )

thanks.

It’s basically the same except the method for creating URLs: http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html

thanks :)

function addcartajax(id,OrgName)

	 {


		


		


		


		var a="<?php echo \Yii::$app->getUrlManager()->createUrl(['products/cart','ac'=>'add'])?>&pid="+id+"&org="+OrgName;


	


		


		jQuery.get(a,function(data,status){


					alert(data);


				});


		 


	}	

this works