traprajith
(Traprajith)
September 24, 2012, 12:22pm
1
<?php $form=$this->beginWidget('CActiveForm', array(
'method'=>'GET',
)); ?>
<input type="search" placeholder="search" name="name" value="<?php echo isset($_GET['name']) ? CHtml::encode($_GET['name']) : '' ; ?>" />
<?php
echo CHtml::ajaxButton("Apply",
CController::createUrl('/site/manage'),
array('update' => '#student_panel_handler','type'=>'GET',
));
?>
<?php $this->endWidget(); ?>
not getting anything to the action? is there any solution?
when i use ajaxSubmitButton its posting the value
<?php $form=$this->beginWidget('CActiveForm', array(
'method'=>'GET',
)); ?>
<input type="search" placeholder="search" name="name" value="<?php echo isset($_GET['name']) ? CHtml::encode($_GET['name']) : '' ; ?>" />
<?php
echo CHtml::ajaxSubmitButton ("Apply",
CController::createUrl('/site/manage'),
array('update' => '#student_panel_handler',
));
?>
<?php $this->endWidget(); ?>
but need ajax with GET
is there any solution?
Keith
(Kburton)
September 24, 2012, 12:41pm
2
Try
echo CHtml::ajaxSubmitButton ("Apply",
CController::createUrl('/site/manage'),
array(
'update' => '#student_panel_handler',
'type' => 'GET',
)
);
EDIT:
That won’t work because the type is explicitly overridden in the method call. You’ll have to use a different control. Here’s the source:
public static function ajaxSubmitButton($label,$url,$ajaxOptions=array(),$htmlOptions=array())
{
$ajaxOptions['type']='POST';
$htmlOptions['type']='submit';
return self::ajaxButton($label,$url,$ajaxOptions,$htmlOptions);
}
traprajith
(Traprajith)
September 24, 2012, 12:48pm
3
thank u
its not working
i need ajaxbutton for submiting a form.
ajaxSubmitButton will always POST the form
softark
(Softark)
September 24, 2012, 1:04pm
4
What about this?
<?php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'search-form',
'method'=>'GET',
));
...
echo CHtml::ajaxButton("Apply",
CController::createUrl('/site/manage'),
array(
'data' => '$("#search-form").serialize()',
'update' => '#student_panel_handler',
'type'=>'GET',
)
);
traprajith
(Traprajith)
September 24, 2012, 2:03pm
5
thank u softark
but its not getting to action
traprajith
(Traprajith)
September 24, 2012, 2:06pm
6
this is getting
Array ( [r] => site/manage [$("] => )
softark
(Softark)
September 24, 2012, 2:19pm
7
Um, sorry.
What about this?
'data' => 'js:$("#search-form").serialize()',
Or
'data' => new CJavaScriptExpression('$("#search-form").serialize()'),
oxigen
(Vanminh0312)
September 24, 2012, 3:10pm
8
Inpspecting Form you can see follow code:
<div style="display:none">
<input type="hidden" name="r" value="<you route different site/manage>">
</div>
you have this issue because of this code in ajaxButton:
,'data':jQuery(this).parents("form").serialize()
hidden field name=r will override r value of url in ajaxButton
2 ways to fix this issue:
change ‘method’=>‘GET’, ‘method’=>‘POST’,
use js remove hidden field with name = r if you still want to use ‘method’=>‘GET’,
$('input[‘name=“r”]’).remove();
traprajith
(Traprajith)
September 25, 2012, 9:09am
9
thank u softark…its working…
mdomba
(Maurizio Domba Cerin)
September 25, 2012, 10:09am
10