How to render a view in a portion of page but without reload 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
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.