Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/248.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在IFrame中使用ajax_Php_Ajax_Iframe_Yii - Fatal编程技术网

Php 在IFrame中使用ajax

Php 在IFrame中使用ajax,php,ajax,iframe,yii,Php,Ajax,Iframe,Yii,在我的站点中,我有一个iframe,其中包含一个Chtml::ajaxButton。我已经找到了很多关于这个问题的帖子,但是没有找到解决方案 我认为重要的是要强调的是,这个iframe没有被用来将数据发送到与主机页不同的域 view.php <div style="height: 385px; width: 350px; overflow: hidden"> <?php $url = "displayMessages?league_id=

在我的站点中,我有一个iframe,其中包含一个Chtml::ajaxButton。我已经找到了很多关于这个问题的帖子,但是没有找到解决方案

我认为重要的是要强调的是,这个iframe没有被用来将数据发送到与主机页不同的域

view.php

        <div style="height: 385px; width: 350px; overflow: hidden">
            <?php $url = "displayMessages?league_id=".$model->id; ?>
            <iframe src="<?php print $url?>" width="350" height="385">
            </iframe>
        </div>
public function actionDisplayMessages()
{
    if(isset($_GET['league_id'])){
        $selectedLeague = $_GET['league_id'];
        $league = LigasDeAmigos::model()->findByPk((int)$selectedLeague);
        $user = (int)Yii::app()->user->id;
        $this->renderPartial('leagueWallMessages', array(
                                                    'model'=>$league,
                                                    'messages'=>$league->messages,
                                                    'user'=>$user,
        ));
    }       
}
<?php 
    echo CHtml::ajaxButton(
        "Compartir", CController::createUrl('leagues/insertComment',
    array(
        'league_id'=>$model->id)),
        array(
            'success' => "js: function(){ alert('Success!!'); }",
            'type' => 'post',
        ),
        array(
            'id'=>'idButtonShare',
            'style'=>'width:70px;height:40px; align:right;'
        )
    );
?>
LeagueWallMessages.php

        <div style="height: 385px; width: 350px; overflow: hidden">
            <?php $url = "displayMessages?league_id=".$model->id; ?>
            <iframe src="<?php print $url?>" width="350" height="385">
            </iframe>
        </div>
public function actionDisplayMessages()
{
    if(isset($_GET['league_id'])){
        $selectedLeague = $_GET['league_id'];
        $league = LigasDeAmigos::model()->findByPk((int)$selectedLeague);
        $user = (int)Yii::app()->user->id;
        $this->renderPartial('leagueWallMessages', array(
                                                    'model'=>$league,
                                                    'messages'=>$league->messages,
                                                    'user'=>$user,
        ));
    }       
}
<?php 
    echo CHtml::ajaxButton(
        "Compartir", CController::createUrl('leagues/insertComment',
    array(
        'league_id'=>$model->id)),
        array(
            'success' => "js: function(){ alert('Success!!'); }",
            'type' => 'post',
        ),
        array(
            'id'=>'idButtonShare',
            'style'=>'width:70px;height:40px; align:right;'
        )
    );
?>

原来我忘了在表单定义中包含按钮。我将按钮和其他内容放在表单中,并将按钮更改为
ajaxSubmitButton