function LoadPage (page) {
// each page contains 10 pictures
var endp = page*10;
// Empty the main container that contains the pictures
$('#container').empty();
// Rewrite the Page Menu
for (j=1;j<Math.abs(len/10);j++) {
$('#container').append("<a href='javascript: LoadData("+j+")'>"+j+"</a>");
}
// Add the image containers containing images
for (i=endp-10;i<endp;i++) {
$('#container').append("<div class='container' id="+i+" >");
$('#'+i).append("<img src="+x[i].getElementsByTagName('URL')[0].childNodes[0].nodeValue+" width='200'>");
$('#container').append("</div>");
}
// Have to call a function ' wall.reload(); ' once all the pictures are loaded!
setTimeout(function(){
if (wall) { wall.reload(); }
},2000);
}
この関数は、ページ番号を指定して複数回呼び出されます。すべてが正常に機能しています。setTimeout() 関数を使用して関数 wall.reload() を遅らせていますが、そうしたくありません。むしろ、すべての画像が読み込まれるまで関数を待機させてから、wall.reload() を起動する必要があります。
ありがとう。