function(headers, callback) {
                    // setup all variables
                    var xhr = new XMLHttpRequest(),
                        url = options.url,
                        type = options.type,
                        async = options.async || true,
                        // blob or arraybuffer. Default is blob
                        dataType = options.responseType || "blob",
                        data = options.data || null,
                        username = options.username || null,
                        password = options.password || null;

                    xhr.addEventListener('load', function() {
                        var data = {};
                        data[options.dataType] = xhr.response;
                        // make callback and send data
                        callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
                    });
                    xhr.addEventListener('error', function() {
                        var data = {};
                        data[options.dataType] = xhr.response;
                        // make callback and send data
                        callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
                    });

                    xhr.open(type, url, async, username, password);

                    // setup custom headers
                    for (var i in headers) {
                        xhr.setRequestHeader(i, headers[i]);
                    }

                    xhr.responseType = dataType;
                    xhr.send(data);
                }
function(headers, callback) {
                    
                    var xhr = new XMLHttpRequest(),
                        url = options.url,
                        type = options.type,
                        async = options.async || true,
                        
                        dataType = options.responseType || "blob",
                        data = options.data || null,
                        username = options.username || null,
                        password = options.password || null;

                    xhr.addEventListener('load', function() {
                        var data = {};
                        data[options.dataType] = xhr.response;
                        
                        callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
                    });
                    xhr.addEventListener('error', function() {
                        var data = {};
                        data[options.dataType] = xhr.response;
                        
                        callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
                    });

                    xhr.open(type, url, async, username, password);

                    
                    for (var i in headers) {
                        xhr.setRequestHeader(i, headers[i]);
                    }

                    xhr.responseType = dataType;
                    xhr.send(data);
                }
function ( headers , callback ) { // setup all variables var xhr = new XMLHttpRequest ( ) , url = options . url , type = options . type , async = options . async || true , // blob or arraybuffer. Default is blob dataType = options . responseType || "blob" , data = options . data || null , username = options . username || null , password = options . password || null ; xhr . addEventListener ( 'load' , function ( ) { var data = { } ; data [ options . dataType ] = xhr . response ; // make callback and send data callback ( xhr . status , xhr . statusText , data , xhr . getAllResponseHeaders ( ) ) ; } ) ; xhr . addEventListener ( 'error' , function ( ) { var data = { } ; data [ options . dataType ] = xhr . response ; // make callback and send data callback ( xhr . status , xhr . statusText , data , xhr . getAllResponseHeaders ( ) ) ; } ) ; xhr . open ( type , url , async , username , password ) ; // setup custom headers for ( var i in headers ) { xhr . setRequestHeader ( i , headers [ i ] ) ; } xhr . responseType = dataType ; xhr . send ( data ) ; }
create new XMLHttpRequest
create new XMLHttpRequest