era
era

Reputation: 535

Ajax Submit in Yii

I am using a CActive Form and, earlier i was having a normal submit button. Then I changed it to an Ajax Button like as follows,

CHtml::ajaxSubmitButton('Continue',CController::createUrl('//shop/order/create&store=true'),array('type'=>'POST'));

This goes to the url when u refresh the page. But i want it to go to the page without page refresh. Any idea how do it?

Thanks in advance.

Upvotes: 2

Views: 4264

Answers (2)

seeppp
seeppp

Reputation: 322

try this, with some ajax success functionallity...

echo CHtml::ajaxSubmitButton('BottonLabel',
                             Yii::app()->createUrl('your/url',array('calltype' => 'system')),
                             array('type' => 'POST',
                             'cache' => true or false,
                             'success' => 'js:function(data) {yourJSfunction(data)}'),
                             array('id' => 'the_id'));

or follow this link to the class-reference for yii ajaxSubmitButton

Upvotes: 1

Owais Iqbal
Owais Iqbal

Reputation: 549

try this..

array('contoller_name/action','ajax'=>'somevalue'));
//In your case
echo CHtml::ajaxSubmitButton('Continue',array('contoller_name/action','ajax'=>'yw0'));

Just keep in mind that you are obviously setting auto created widget ids as params (yw0). You should assign your own ids to widgets, otherwise another widget could have the same id and that can be hard to debug..

Upvotes: 0

Related Questions