Changes
Title
changed
Update content in AJAX with partialRenderrenderPartial
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
AJAX
Content
changed
The
most easyeasiest way to update content in AJAX is to use the
partialRenderrenderPartial method.
For this exemple I have three files: a controller (HelloWorldController.php) and two views (index.php and _ajaxContent.php)[...]
```php
class HelloWorldController extends CController
{
public function actionIndex()[...]
<br />
*Note: if using accessRules() in your controller file, you will need to modify accessRules() by adding the appropriate part of the function name to a rule set - in this case* 'updateajax' *like this:*
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view','updateajax'),
'users'=>array('*'),
),
#### views/hello
World/index.php
```php[...]
<?php echo CHtml::ajaxButton ("Update data",
CController::createUrl('helloWorld/UpdateAjax'),
array('update' => '#data'));
?>[...]
<br />
#### views/helloWorld/_ajaxContent.php
```php[...]
<br />
Now, run index.php?r=helloWorld
Enjoy!
### Links
- [Russian Version](http://dbhelp.ru/ajax-partialrender-update/page/)