简体   繁体   中英

How to call ajax through Bootstrap button in yii

I want to use Ajax through bootstrap button in Yii, and want to pass textfield values though that Ajax call.

here's the button code, where should i put the Ajax code for this button.

   <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'button', 'label'=>'ADD')); ?> 

try this

  <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'button', 'label'=>'ADD',

     'ajaxOptions' => array(
                    'type' => 'Post',
                    'url' => $this->createURL('url'),
                    'data' => Yii::app()->request->csrfTokenName."=".Yii::app()->request->getCsrfToken()."&action=cancel",
                    'success'=>"js:function(vals){


                    }",
                    )
    )); ?>

another eg:

$this->widget('bootstrap.widgets.TbButton', array(
                 'buttonType' => 'ajaxButton',
                 'label' => 'Label Here',
                 'type' => 'danger',
                 'icon' => 'play white',
                 ...
                 'ajaxOptions' => array(
                     'success' => '...',
                     'error' => '...',
                     'beforeSend' => '...',
                 )
             ));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM