js/NativeXhrDataProvider.js
function (params) {
            var xhr = new XMLHttpRequest(),
                async = typeof (params.asynchronous) === "boolean" ? params.asynchronous : this.asynchronous,

                readystatechange = function () {
                    if (params.onreadystatechange) {
                        params.onreadystatechange.call(this);
                    } else {
                        if (this.readyState === this.DONE) {
                            if (!this.loadcalled) { // prevent multiple done calls from xhr.
                                var resp;
                                if (!xhr.timedOut) {
                                    resp = this.response || this.responseText;
                                }
                                this.loadcalled = true;
                                if (resp && !this.responseType &&
                                        params.responseType === "json") {
                                    try {
                                        resp = JSON.parse(resp);
                                    } catch (e) {
                                        logger.debug('Unable to parse JSON: ' + resp + '\n' + e);
                                    }
                                }

                                params.handler.call(this, (xhr.timedOut) ? -1 : this.status, resp, params);
                            }
                        }
                    }
                };

            // setup pre-open parameters
            params.xhr = xhr;

            if (params.responseType && typeof (xhr.responseType) === 'string') {
                // types for level 2 are still draft. Don't attempt to set until
                // support is more universal.
                //
                // xhr.responseType = params.responseType;
                logger.debug("Ignoring responseType on XHR until fully supported.");
            }

            xhr.open(params.method, params.url, async);
            Object.keys((params.headers || {})).forEach(function (val) {
                if (!(val === "Content-Type" && params.headers[val] === "multipart/form-data")) {
                    xhr.setRequestHeader(val, params.headers[val]);
                }
            });

            // If level 2, then attach the handlers directly.
            if (xhr.upload) {
                Object.keys(params).forEach(function (key) {
                    if (key.indexOf("on") === 0 && typeof (params[key]) === 'function') {
                        if (typeof (xhr[key]) !== 'undefined') {
                            xhr[key] = params[key];
                        }
                        if (typeof (xhr.upload[key]) !== 'undefined') {
                            xhr.upload[key] = params[key];
                        }
                    }
                });
            }
            // still support readystate event.
            if (params.handler || params.onreadystatechange) {
                xhr.onreadystatechange = readystatechange;
            }

            if (params.timeout && typeof (params.timeout) === 'number') {
                xhr.timeout = params.timeout;
                xhr.ontimeout = function () {
                    xhr.timedOut = true;
                    xhr.abort();
                };
                setTimeout(function () {  /* vs. xhr.timeout */
                    this.response = {};
                    if (xhr.readyState < 4 && !xhr.timedOut) {
                        xhr.ontimeout();
                    }
                },  xhr.timeout);
            }
            xhr.send(params.payload);
        }
function (params) {
            var xhr = new XMLHttpRequest(),
                async = typeof (params.asynchronous) === "boolean" ? params.asynchronous : this.asynchronous,

                readystatechange = function () {
                    if (params.onreadystatechange) {
                        params.onreadystatechange.call(this);
                    } else {
                        if (this.readyState === this.DONE) {
                            if (!this.loadcalled) { // prevent multiple done calls from xhr.
                                var resp;
                                if (!xhr.timedOut) {
                                    resp = this.response || this.responseText;
                                }
                                this.loadcalled = true;
                                if (resp && !this.responseType &&
                                        params.responseType === "json") {
                                    try {
                                        resp = JSON.parse(resp);
                                    } catch (e) {
                                        logger.debug('Unable to parse JSON: ' + resp + '\n' + e);
                                    }
                                }

                                params.handler.call(this, (xhr.timedOut) ? -1 : this.status, resp, params);
                            }
                        }
                    }
                };

            // setup pre-open parameters
            params.xhr = xhr;

            if (params.responseType && typeof (xhr.responseType) === 'string') {
                // types for level 2 are still draft. Don't attempt to set until
                // support is more universal.
                //
                // xhr.responseType = params.responseType;
                logger.debug("Ignoring responseType on XHR until fully supported.");
            }

            xhr.open(params.method, params.url, async);
            Object.keys((params.headers || {})).forEach(function (val) {
                if (!(val === "Content-Type" && params.headers[val] === "multipart/form-data")) {
                    xhr.setRequestHeader(val, params.headers[val]);
                }
            });

            // If level 2, then attach the handlers directly.
            if (xhr.upload) {
                Object.keys(params).forEach(function (key) {
                    if (key.indexOf("on") === 0 && typeof (params[key]) === 'function') {
                        if (typeof (xhr[key]) !== 'undefined') {
                            xhr[key] = params[key];
                        }
                        if (typeof (xhr.upload[key]) !== 'undefined') {
                            xhr.upload[key] = params[key];
                        }
                    }
                });
            }
            // still support readystate event.
            if (params.handler || params.onreadystatechange) {
                xhr.onreadystatechange = readystatechange;
            }

            if (params.timeout && typeof (params.timeout) === 'number') {
                xhr.timeout = params.timeout;
                xhr.ontimeout = function () {
                    xhr.timedOut = true;
                    xhr.abort();
                };
                setTimeout(function () {  /* vs. xhr.timeout */
                    this.response = {};
                    if (xhr.readyState < 4 && !xhr.timedOut) {
                        xhr.ontimeout();
                    }
                },  xhr.timeout);
            }
            xhr.send(params.payload);
        }
function ( params ) { var xhr = new XMLHttpRequest ( ) , async = typeof ( params . asynchronous ) === "boolean" ? params . asynchronous : this . asynchronous , readystatechange = function ( ) { if ( params . onreadystatechange ) { params . onreadystatechange . call ( this ) ; } else { if ( this . readyState === this . DONE ) { if ( ! this . loadcalled ) { // prevent multiple done calls from xhr.
 var resp ; if ( ! xhr . timedOut ) { resp = this . response || this . responseText ; } this . loadcalled = true ; if ( resp && ! this . responseType && params . responseType === "json" ) { try { resp = JSON . parse ( resp ) ; } catch ( e ) { logger . debug ( 'Unable to parse JSON: ' + resp + '\n' + e ) ; } } params . handler . call ( this , ( xhr . timedOut ) ? - 1 : this . status , resp , params ) ; } } } } ; // setup pre-open parameters
 params . xhr = xhr ; if ( params . responseType && typeof ( xhr . responseType ) === 'string' ) { // types for level 2 are still draft. Don't attempt to set until
 // support is more universal.
 //
 // xhr.responseType = params.responseType;
 logger . debug ( "Ignoring responseType on XHR until fully supported." ) ; } xhr . open ( params . method , params . url , async ) ; Object . keys ( ( params . headers || { } ) ) . forEach ( function ( val ) { if ( ! ( val === "Content-Type" && params . headers [ val ] === "multipart/form-data" ) ) { xhr . setRequestHeader ( val , params . headers [ val ] ) ; } } ) ; // If level 2, then attach the handlers directly.
 if ( xhr . upload ) { Object . keys ( params ) . forEach ( function ( key ) { if ( key . indexOf ( "on" ) === 0 && typeof ( params [ key ] ) === 'function' ) { if ( typeof ( xhr [ key ] ) !== 'undefined' ) { xhr [ key ] = params [ key ] ; } if ( typeof ( xhr . upload [ key ] ) !== 'undefined' ) { xhr . upload [ key ] = params [ key ] ; } } } ) ; } // still support readystate event.
 if ( params . handler || params . onreadystatechange ) { xhr . onreadystatechange = readystatechange ; } if ( params . timeout && typeof ( params . timeout ) === 'number' ) { xhr . timeout = params . timeout ; xhr . ontimeout = function ( ) { xhr . timedOut = true ; xhr . abort ( ) ; } ; setTimeout ( function ( ) { /* vs. xhr.timeout */ this . response = { } ; if ( xhr . readyState < 4 && ! xhr . timedOut ) { xhr . ontimeout ( ) ; } } , xhr . timeout ) ; } xhr . send ( params . payload ) ; }
Perform the actual XMLHttpRequest call, interpreting the params as necessary.
Although this method accepts the bulk of the parameters that can be set on XMLHttpRequest 2,
only a few are passed through from the upstream calls.

@param params - object of the form:
{
onprogress {function}
onloadstart {function}
onabort {function}
ontimeout {function}
onloadend {function}
onreadystatechange {function}
asynchronous {boolean}
method {String}
headers {Object}
payload {Object}
url {String}
timeout {Number}
responseType {String}
handler {function}
}
Perform the actual XMLHttpRequest call interpreting the params as necessary . Although this method accepts the bulk of the parameters that can be set on XMLHttpRequest 2 only a few are passed through from the upstream calls .