1
//based on prototype's ajax class
2
//to be used with prototype.lite, moofx.mad4milk.net.
6
initialize: function(url, options){
7
this.transport = this.getTransport();
8
this.postBody = options.postBody || '';
9
this.method = options.method || 'post';
10
this.onComplete = options.onComplete || null;
11
this.update = $(options.update) || null;
15
request: function(url){
16
this.transport.open(this.method, url, true);
17
this.transport.onreadystatechange = this.onStateChange.bind(this);
18
if (this.method == 'post') {
19
this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
20
if (this.transport.overrideMimeType) this.transport.setRequestHeader('Connection', 'close');
22
this.transport.send(this.postBody);
25
onStateChange: function(){
26
if (this.transport.readyState == 4 && this.transport.status == 200) {
28
setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10);
30
setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10);
31
this.transport.onreadystatechange = function(){};
35
getTransport: function() {
36
if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
37
else if (window.XMLHttpRequest) return new XMLHttpRequest();
b'\\ No newline at end of file'