[ Index ] |
|
Code source de LifeType 1.2.4 |
1 //based on prototype's ajax class 2 //to be used with prototype.lite, moofx.mad4milk.net. 3 4 ajax = Class.create(); 5 ajax.prototype = { 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; 12 this.request(url); 13 }, 14 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'); 21 } 22 this.transport.send(this.postBody); 23 }, 24 25 onStateChange: function(){ 26 if (this.transport.readyState == 4 && this.transport.status == 200) { 27 if (this.onComplete) 28 setTimeout(function(){this.onComplete(this.transport);}.bind(this), 10); 29 if (this.update) 30 setTimeout(function(){this.update.innerHTML = this.transport.responseText;}.bind(this), 10); 31 this.transport.onreadystatechange = function(){}; 32 } 33 }, 34 35 getTransport: function() { 36 if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP'); 37 else if (window.XMLHttpRequest) return new XMLHttpRequest(); 38 else return false; 39 } 40 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |