ajax onload

Hi there,

I have a view which displays facebook friend pics. The fetching of the friends from facebook however takes a long time, therefore my entire view doesn’t display untill all friends are loaded.

To remedy this, I want to display my view first, and then after the view is loaded, use ajax to fetch and display friends. I’ve followed the ajaxbutton example, and have gotten it to work to fetch and display friends using this code:





<?php

 $data = array();

 $data["myValue"] = "Content updated in AJAX";?>

<div id="data"></div><?php

echo CHtml::ajaxButton ("Update data",

                              CController::createUrl('site/UpdateAjax?code='.$code), 

                              array('update' => '#data'));

?>

however how can I get the "UpdateAjax" function to fire automatically when the page loads up?

Please help! Thanks!

You can`t update ajax data in php $variable or array!,










<?php

echo CHtml::ajaxButton ("Update data",

                              CController::createUrl('site/UpdateAjax?code='.$code), 

                              array(

			'type'=>'POST', //request type

			'error'=>'function(event, request, settings){

                        $("#data").append("Error requesting page " + settings.url);}'

			'update'=>'#data', //selector to update		

			)

			);

?>


<div id="data"></div>