Render a view in a portion without refresh the whole page by using ajax

How to render a view in a portion of page but without reload the whole page by using ajax.


<?php echo CHtml::ajaxLink(

        "Lable di testo",

        CController::createUrl('site/apage'),

        array(

            'update' => '#req_res'

        )

); ?>


<div id="req_res"></div>

And in SiteController::actionApage(); user renderpartial to render the view: /views/site/apage.php

Try

http://www.yiiframework.com/wiki/323/dynamic-parent-and-child-cgridciew-on-single-view-using-ajax-to-update-child-gridview-via-controller-with-many_many-relation-after-row-in-parent-gridview-was-clicked/

jQuery.load() is probably the easiest way to load data asynchronously using a selector, but you can also use any of the jquery ajax methods (get, post, getJSON, ajax, etc.)

Note that load allows you to use a selector to specify what piece of the loaded script you want to load, as in

$("#mydiv").load(location.href + " #mydiv");

Note that this technically does load the whole page and jquery removes everything but what you have selected, but that’s all done internally.