Hi,
i use a ressource with snippet for load some code via ajax :
$data=null;
$menuIndex = $_GET['menuIndex'];
$criteria = $modx->newQuery('modResource');
$criteria->where(array('parent'=>"2",'menuindex'=>$menuIndex));
$resource = $modx->getObject('modResource',$criteria);
$idPage=$resource->get('id');
$urlPage=$modx->makeUrl($idPage,'','','full');
//return $urlPage;
if($http= fopen($urlPage,"r")){
while(!feof($http)){
$data .=fgets($http,1024);
}
fclose($http);
}
preg_match_all('/(<!--DebutContenuArtiste-->)(\W.*)(<!--FinContenuArtiste-->)/imsU',$data,$result);
foreach($result[2] as $contenu){
$contenu;
}
$arr = array ('contenu'=>$contenu);
return json_encode($arr);
I find that the page takes a long time to load.
my question : Is that my way is right?
if no, how to do for optimize my script
Thanks for your help
Laurent
below, my javascript code tel the ressource
url=site_url+"/admin/loadajaxartiste.html?menuIndex="+num;
$.ajax({
dataType:"json",
url :url,
async: false,
beforeSend:function() {
},
success :function(data){
$("#blocArtiste"+num).append(data.contenu);
$("#blocArtiste"+num).css(cssDeb);
$("#blocArtiste"+num).animate({left:0},900);
$("#blocArtiste"+elemCurrent).animate(cssFin,900);
tailleBlocBiographie();
$(".ppt").remove();
$(".pp_overlay").remove();
$(".pp_pic_holder").remove();
jQuery('.jcarousel-skin-dates').jcarousel({
vertical: true,
animation: 800,
visible:4
});
jQuery('.jcarousel-skin-discoGalery').jcarousel({
animation: 800,
visible:3
});
$("a[rel^='prettyPhoto']").prettyPhoto();
JolieScroll();
}