My code is finally working!
AJAX Wrapper enhanced
AJAX Wrapper enhanced
After creating a simple leak free defensive AJAX wrapper, and tweaking a bit to more effectively handle leaks, I found out that under certain (really uncommon, infrequent and abnormal) situations the object can still leak a little bit of memory.So I decided to attach an onunload handler to the constructor and get rid of the leaks for good.In addition, I enhanced the object further. It will be available to the rest of the world when I release the new version of sardalya. But for you lucky guys out there, I'm pasting entire code below./** XHRequest ----- **/function XHRequest(){ this._fields=[]; this._values=[]; this._initialized=false; this.init(); }_this=XHRequest.prototype;_this.removeAllFields=function(){ this._fields.length=0; this._values.length=0;};_this.addField=function(strField,strValue){ this._fields.push(strField); this._values.push(TextFormatter.escape(strValue));};_this.post=function(strURL,_blnSync){ if(!this._xhr) { return; } if(!_blnSync) { _blnSync=false; } var uq=this._generateURL(strURL); this._xhr.open("POST",uq.url,!_blnSync); this._setRequestHeaders(); this._xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
AJAX Wrapper enhanced
After creating a simple leak free defensive AJAX wrapper, and tweaking a bit to more effectively handle leaks, I found out that under certain (really uncommon, infrequent and abnormal) situations the object can still leak a little bit of memory.So I decided to attach an onunload handler to the constructor and get rid of the leaks for good.In addition, I enhanced the object further. It will be available to the rest of the world when I release the new version of sardalya. But for you lucky guys out there, I'm pasting entire code below./** XHRequest ----- **/function XHRequest(){ this._fields=[]; this._values=[]; this._initialized=false; this.init(); }_this=XHRequest.prototype;_this.removeAllFields=function(){ this._fields.length=0; this._values.length=0;};_this.addField=function(strField,strValue){ this._fields.push(strField); this._values.push(TextFormatter.escape(strValue));};_this.post=function(strURL,_blnSync){ if(!this._xhr) { return; } if(!_blnSync) { _blnSync=false; } var uq=this._generateURL(strURL); this._xhr.open("POST",uq.url,!_blnSync); this._setRequestHeaders(); this._xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
0 Comments:
Post a Comment
<< Home