私は現在、JSON と jQuery (そしてもちろん PHP) を使用して、アクティビティ フィード/ニュース フィードまたは並べ替えを構築しています。特に新しい結果をフェッチするなど、すべてが非常にうまく機能します。唯一の問題は最初の読み込みです。結果をより滑らかにするために、結果をプリロードする方法があるかどうか疑問に思っています。
以下のjQueryコード:
for (var j = 0; j < jsonData.items.length; j++) {
var entryData = jsonData.items[j];
var entry = template.clone();
entry.removeClass("template");
entry.find(".message").text(entryData.statusid);
entry.find(".actName").text(entryData.name);
entry.find(".actContent").text(entryData.content);
//get the users ProfilePic
var profileImg = $("<img />");
profileImg.attr("src", "./img/" +entryData.profilePic);
profileImg.addClass("feed-user-img");
entry.find(".actProfilePic").append(profileImg);
//Get user-uploaded images.
entry.find(".actImage").text(entryData.imageKey);
if (entryData.imageKey != "")
{
var img = $("<img />"); // Create the image element
img.attr("src", "http://spartadev.s3.amazonaws.com/" + entryData.imageKey); // Set src to the s3 url plus the imageKey
entry.find(".actImage").append(img); // Append it to the element where it's supposed to be
}
spot.prepend(entry);
spot.find(".entry").first().hide().slideDown();
}