Ajaxsubmitbutton

apply ajax,code like this

echo CHtml::ajaxsubmitbutton(’’,

Yii::app()->createUrl(’/User/addcart’),

array(

‘data’ =>array(‘ID’=>$model->id,

[color="#FF0000"]qty_item_1[/color]’=>????,

‘user’=>Yii::app()->user->id),

‘type’=>‘POST’,

‘update’=>’$(#buynum).text(data)’

),

array(‘class’=>‘cartbutton’)

);

qty_item_1 is the id of input,like this

<input type="text" name="[color="#FF0000"]qty_item_1[/color]" value="1" id="qty_item_1"/>

if changed the value of the input ,how i use the ajax with data param? :blink:

ignore the data key in the ajaxSubmitButton. by doing this the yii will automatically post the value of text box to your action automatically :)

I yet think so ,but it don’t work,the action like as:

public function actionAddcart()

{


	&#036;ID = &#036;_POST['ID'];


	&#036;user = &#036;_POST['user'];


	&#036;num = &#036;_POST['qty_item_1'];


	


	if(Yii::app()-&gt;request-&gt;isAjaxRequest)


	{


	&#036;comm = YII::app()-&gt;db-&gt;createcommand();


           ...

it looks like the action didn’t get the value of qty_item_1

dump the posted values like


CVarDumper::dump($_REQUEST);

refer manuals about ajax here