hey,
I have an action in my controller which performs $this->render when i change a value in a Dropdownlist. This is done by AJAX and JQUERY. Unfortunately the only thing that happens is that in the POST response there is the whole page that should be rendered. But the page itself does not update. Why is that?
In my view:
In my Controller:
and
So in conclusion: I click on an entry in the dropdown, I see nothing but when I look at the Post response via firebug I see that the whole page that should be rendered is the response of the request.
I have an action in my controller which performs $this->render when i change a value in a Dropdownlist. This is done by AJAX and JQUERY. Unfortunately the only thing that happens is that in the POST response there is the whole page that should be rendered. But the page itself does not update. Why is that?
In my view:
Yii::app()->clientScript->registerScript('show', " $('#cat0_name').change(function() { loadData(); }); function loadData() { $.ajax( { type: 'POST', url: '".CController::createUrl('loadCategories')."', data: { cat: $('#cat0_name').val() }, success: function (data) { $('#test').html(data); } }); } ");
In my Controller:
public function actionLoadCategories() { if(isset($_POST['cat'])) { $cat = $_POST['cat']; $this->actionIndex(array('category'=>$cat)); } }
and
public function actionIndex($array=null) { $criteria=new CDbCriteria(); if($array) { foreach($array AS $key => $value) { $criteria->compare($key,$value); } } $dataProvider=new CActiveDataProvider('Objects',array( 'criteria'=>$criteria, 'pagination'=>array( 'pageSize'=>20, ))); if(Yii::app()->request->isAjaxRequest) { $this->renderPartial('index',array( 'conditions' => $array, 'dataProvider'=>$dataProvider),false,true); } else { $this->render('index',array( 'conditions' => $array, 'dataProvider'=>$dataProvider)); } }
So in conclusion: I click on an entry in the dropdown, I see nothing but when I look at the Post response via firebug I see that the whole page that should be rendered is the response of the request.