ajith
(Ajith Tejas)
April 16, 2015, 12:39pm
1
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.
samdark
(Alexander Makarov)
April 18, 2015, 7:07am
2
It’s basically the same except the method for creating URLs: http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html
ajith
(Ajith Tejas)
April 18, 2015, 12:06pm
4
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