繁体   English   中英

如何通过yii中的Bootstrap按钮调用Ajax

[英]How to call ajax through Bootstrap button in yii

我想通过Yii中的引导按钮使用Ajax,并希望通过该Ajax调用传递文本字段值。

这是按钮代码,我应该在哪里放置该按钮的Ajax代码。

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

尝试这个

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


                    }",
                    )
    )); ?>

另一个例如:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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