2011-06-30 24 views
0

在我的網站中,我有一個iframe,其中包含一個Chtml :: ajaxButton。我發現很多關於這個問題的帖子,但找不到解決方案。在IFrame中使用ajax

我認爲重要的是要強調的是,這個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> 

LeaguesController.php

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, 
     )); 
    }  
} 

LeagueWallMessages.php

<?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中的這個按鈕,點擊後,不會觸發任何操作。什麼可能導致這個問題?

回答

1

原來我忘記了在表單定義中使用按鈕。我將按鈕和其他內容放置在一個表格中,並更改了ajaxSubmitButton的按鈕。