Ajaxbutton Problem




<?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?

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);

}



thank u

its not working

i need ajaxbutton for submiting a form.

ajaxSubmitButton will always POST the form

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',

         )

);



thank u softark

but its not getting to action

this is getting

Array ( [r] => site/manage [$("] => )

Um, sorry.

What about this?




    'data' => 'js:$("#search-form").serialize()',



Or




    'data' => new CJavaScriptExpression('$("#search-form").serialize()'),



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:

  1. change ‘method’=>‘GET’, ‘method’=>‘POST’,

  2. use js remove hidden field with name = r if you still want to use ‘method’=>‘GET’,

$('input[‘name=“r”]’).remove();

thank u softark…its working…

GutHub issue - https://github.com/yiisoft/yii/issues/1465