Php 在IFrame中使用ajax
在我的站点中,我有一个iframe,其中包含一个Chtml::ajaxButton。我已经找到了很多关于这个问题的帖子,但是没有找到解决方案 我认为重要的是要强调的是,这个iframe没有被用来将数据发送到与主机页不同的域 view.phpPhp 在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=
<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