写真共有プログラム

photoShare = new Object();
// 画像のURLを登録
photoShare.addURL = function() {
var url = "regist.cgi?saveURL="+$F("siteURL")+"&cache="+(new Date()).getTime();
new Ajax.Request(url, { method: "get", onComplete:photoShare.getURL });
}
// 画像のURLを取得
photoShare.getURL = function() {
var url = "read.cgi?cache="+(new Date()).getTime();
new Ajax.Request(url, { method: "get",
onComplete: function(httpObj) {
var LF = String.fromCharCode(10);
var List = httpObj.responseText.split(LF);
for (var i=0; i<List.length; i++) $("img"+i).src = List[i];
}
});
$("siteURL").focus();
}
// 画像を開く
photoShare.openImage = function(sURL) {
subWin = window.open(sURL,"img","width=480,height=360,menubar=no,toolbar=no");
}
// imgタグを生成する
photoShare.makeImage = function() {
var total = 20; // 生成する画像の数
for (var i=0; i<total; i++) {
document.write('<img src="none.gif" class="photo" id="img'+i+'" onClick="photoShare.openImage(this.src)">');
}
}

window.onload = function() {
$("ajaxForm").onsubmit = function () {
photoShare.addURL();
return false;
}
photoShare.getURL();
}

・サンプルを実行
・サンプルをダウンロード
Ajax実践テクニック 説明などは本書を参考にしてください。JavaScript以外のソースはデータをダウンロードするか本書を参照してください。