prototype.js
会社の勉強会でちょっと火がつきました。やっぱり、Ajaxの説明はprototype.jsからかな。
Prototype is a JavaScript framework that aims to ease development of dynamic web applications.
ブラウザ毎の「XMLHttpRequest」違いも、「try catch」でごりごりやらなくても、「Try.these」を利用して
var Ajax = { getTransport: function() { return Try.these( function() {return new ActiveXObject('Msxml2.XMLHTTP')}, function() {return new ActiveXObject('Microsoft.XMLHTTP')}, function() {return new XMLHttpRequest()} ) || false; } }
これでOKだし、さらにこのように生で使用することなしに、ラッピングされていて「Ajax.Request」を下記のように使用するためのフレームワークですね。
var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onComplete: showResponse} );
「Request」の他に、「Updater」があり、HTMLの部分書き換えなどがこれで行なえます。