javascript - How to pass extra data content on yii activeform's ajax parameters? -


i trying set ajax request when radio button clicked. here code trying for.

<?php echo $form->dropdownlistrow($model, 'page', $pages, array('class' => 'span5', 'prompt' => '-- page --')); ?>      <?php echo $form->radiobuttonlistinlinerow($model, 'for', array('desktop'=>'desktop', 'mobile'=>'mobile'), array('ajax' => array(     'type'=>'post',      'url'=>yii::app()->createurl('/admin/adv/loadpositions'), //or $this->createurl('loadcities') if '$this' extends ccontroller     'update'=>'#adv_position', //or 'success' => 'function(data){...handle data in way want...}',     'data'=>array('for'=>'js:this.value', 'page' => 'xxxxxxxx'),     )));  ?> 

i want pass its's value it's upper field's value ajax action. how can make come true. 'data'=>array('for'=>'js:this.value', 'page' => 'xxxxxxxx'),. in advance.

$(this.form).serialize()

will give form data. try like:

<?php  echo $form->radiobuttonlist($model, 'for', array('desktop'=>'desktop', 'mobile'=>'mobile'), array('ajax' => array( 'type'=>'post',  'url'=>yii::app()->createurl('/admin/adv/loadpositions'),      'data'=>array('data'=>'js:$(this.form).serialize()'), )));  ?> 

update:

you can parse serialized string using php function parse_str

 <?php  $data = 'str1=value1&str2=value2';  parse_str($data);     echo $str1; //value1  echo $str2; //value2 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -