by
21
8
532k
2
Top 1% !
Popular
Pearl of Wisdom
Nice
Useful
Easy-to-find
Specified
Pattern
Popularity: 1233rd place
Created
Modified Dec 1, 2015
Languagejavascript
LicenseMIT_X11
TechnologyAJAX

Ajax again?? Wrap it!! XHR Agent 4Ya

XHR wrapper! object pooling and cueing!!!  EveryOneZ dOing IT!
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/217250/Ajax-again??-Wrap-it!!-XHR-Agent-4Ya?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
var myXHR = { ESpec: function (wrap, evt) { return { xhrWrap: wrap, event: evt }; }, Agent: function(maxConnect) { var bCued = [], slf = this, max = maxConnect || 3; this.curCon = 0; function inCue() { if (self.bCued < max) { self.bCued++; var itm = is.Readied.shift(); itm.evt.addEventListener(['EVENT_COMPLETE'], function (e) { self.bCued--; if (this.Readied.length !== 0) { inCue(); } }); itm.wrap.call(itm, args, itm.evt); } } this.Readied = function (ESpec) { bCued.push(ESpec); inCue(); return ESpec.evt; }; } };
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus