acquire.js
function(url, success, fail) {
        success = success || noop;
        fail = fail || noop;

        //if there's a queue
        if (queue[url] instanceof Array) {
            //just add it
            return queue[url].push({
                success: success,
                fail: fail
            });
        }

        //otherwise there is not a queue
        //so let's create one
        queue[url] = [{
            success: success,
            fail: fail
        }];

        var xhr;

        if(typeof XMLHttpRequest !== 'undefined') {
            xhr = new XMLHttpRequest();
        } else {
            var versions = [
                'MSXML2.XmlHttp.5.0',
                'MSXML2.XmlHttp.4.0',
                'MSXML2.XmlHttp.3.0',
                'MSXML2.XmlHttp.2.0',
                'Microsoft.XmlHttp'];

             for(var i = 0; i < versions.length; i++) {
                try {
                    xhr = new ActiveXObject(versions[i]);
                    break;
                }
                catch(e){}
             }
        }

        if(!xhr) {
            //fail the queue
            queue[url].forEach(function(callback) {
                callback.fail(null);
            });

            delete queue[url];
            return;
        }

        var process = function() {
            if(xhr.readyState < 4) {
                return;
            }

            if(xhr.status >= 404 && xhr.status < 600) {
                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.fail(xhr);
                });

                delete queue[url];
                return;
            }

            if(xhr.status !== 200) {
                return;
            }

            // all is well
            if(xhr.readyState === 4) {
                var response = xhr.responseText;

                try {
                    response = JSON.parse(response);
                } catch(e) {}

                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.success(response, xhr);
                });

                delete queue[url];
            }
        };

        xhr.onreadystatechange = process;
        xhr.open('GET', url, true);
        xhr.send('');
    }
function(url, success, fail) {
        success = success || noop;
        fail = fail || noop;

        //if there's a queue
        if (queue[url] instanceof Array) {
            //just add it
            return queue[url].push({
                success: success,
                fail: fail
            });
        }

        //otherwise there is not a queue
        //so let's create one
        queue[url] = [{
            success: success,
            fail: fail
        }];

        var xhr;

        if(typeof XMLHttpRequest !== 'undefined') {
            xhr = new XMLHttpRequest();
        } else {
            var versions = [
                'MSXML2.XmlHttp.5.0',
                'MSXML2.XmlHttp.4.0',
                'MSXML2.XmlHttp.3.0',
                'MSXML2.XmlHttp.2.0',
                'Microsoft.XmlHttp'];

             for(var i = 0; i < versions.length; i++) {
                try {
                    xhr = new ActiveXObject(versions[i]);
                    break;
                }
                catch(e){}
             }
        }

        if(!xhr) {
            //fail the queue
            queue[url].forEach(function(callback) {
                callback.fail(null);
            });

            delete queue[url];
            return;
        }

        var process = function() {
            if(xhr.readyState < 4) {
                return;
            }

            if(xhr.status >= 404 && xhr.status < 600) {
                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.fail(xhr);
                });

                delete queue[url];
                return;
            }

            if(xhr.status !== 200) {
                return;
            }

            // all is well
            if(xhr.readyState === 4) {
                var response = xhr.responseText;

                try {
                    response = JSON.parse(response);
                } catch(e) {}

                //fail the queue
                queue[url].forEach(function(callback) {
                    callback.success(response, xhr);
                });

                delete queue[url];
            }
        };

        xhr.onreadystatechange = process;
        xhr.open('GET', url, true);
        xhr.send('');
    }
function ( url , success , fail ) { success = success || noop ; fail = fail || noop ; //if there's a queue if ( queue [ url ] instanceof Array ) { //just add it return queue [ url ] . push ( { success : success , fail : fail } ) ; } //otherwise there is not a queue //so let's create one queue [ url ] = [ { success : success , fail : fail } ] ; var xhr ; if ( typeof XMLHttpRequest !== 'undefined' ) { xhr = new XMLHttpRequest ( ) ; } else { var versions = [ 'MSXML2.XmlHttp.5.0' , 'MSXML2.XmlHttp.4.0' , 'MSXML2.XmlHttp.3.0' , 'MSXML2.XmlHttp.2.0' , 'Microsoft.XmlHttp' ] ; for ( var i = 0 ; i < versions . length ; i ++ ) { try { xhr = new ActiveXObject ( versions [ i ] ) ; break ; } catch ( e ) { } } } if ( ! xhr ) { //fail the queue queue [ url ] . forEach ( function ( callback ) { callback . fail ( null ) ; } ) ; delete queue [ url ] ; return ; } var process = function ( ) { if ( xhr . readyState < 4 ) { return ; } if ( xhr . status >= 404 && xhr . status < 600 ) { //fail the queue queue [ url ] . forEach ( function ( callback ) { callback . fail ( xhr ) ; } ) ; delete queue [ url ] ; return ; } if ( xhr . status !== 200 ) { return ; } // all is well if ( xhr . readyState === 4 ) { var response = xhr . responseText ; try { response = JSON . parse ( response ) ; } catch ( e ) { } //fail the queue queue [ url ] . forEach ( function ( callback ) { callback . success ( response , xhr ) ; } ) ; delete queue [ url ] ; } } ; xhr . onreadystatechange = process ; xhr . open ( 'GET' , url , true ) ; xhr . send ( '' ) ; }
Gets a file remotely
and caches it.

@param string
@param function success callback
@param function fail callback
@return void
Gets a file remotely and caches it .