dist/crocodoc.viewer.js
function doXHR(url, method, data, headers, withCredentials, success, fail) {
        var req = support.getXHR();
        req.open(method, url, true);
        req.onreadystatechange = function () {
            var status;
            if (req.readyState === 4) { // DONE
                // remove the onreadystatechange handler,
                // because it could be called again
                // @NOTE: we replace it with a noop function, because
                // IE8 will throw an error if the value is not of type
                // 'function' when using ActiveXObject
                req.onreadystatechange = function () {};

                try {
                    status = req.status;
                } catch (e) {
                    // NOTE: IE (9?) throws an error when the request is aborted
                    fail(req);
                    return;
                }

                // status is 0 for successful local file requests, so assume 200
                if (status === 0 && isRequestToLocalFile(url)) {
                    status = 200;
                }

                if (isSuccessfulStatusCode(status)) {
                    success(req);
                } else {
                    fail(req);
                }
            }
        };
        setHeaders(req, headers);

        // this needs to be after the open call and before the send call
        req.withCredentials = withCredentials;

        req.send(data);
        return req;
    }
function doXHR(url, method, data, headers, withCredentials, success, fail) {
        var req = support.getXHR();
        req.open(method, url, true);
        req.onreadystatechange = function () {
            var status;
            if (req.readyState === 4) { // DONE
                // remove the onreadystatechange handler,
                // because it could be called again
                // @NOTE: we replace it with a noop function, because
                // IE8 will throw an error if the value is not of type
                // 'function' when using ActiveXObject
                req.onreadystatechange = function () {};

                try {
                    status = req.status;
                } catch (e) {
                    // NOTE: IE (9?) throws an error when the request is aborted
                    fail(req);
                    return;
                }

                // status is 0 for successful local file requests, so assume 200
                if (status === 0 && isRequestToLocalFile(url)) {
                    status = 200;
                }

                if (isSuccessfulStatusCode(status)) {
                    success(req);
                } else {
                    fail(req);
                }
            }
        };
        setHeaders(req, headers);

        // this needs to be after the open call and before the send call
        req.withCredentials = withCredentials;

        req.send(data);
        return req;
    }
function doXHR ( url , method , data , headers , withCredentials , success , fail ) { var req = support . getXHR ( ) ; req . open ( method , url , true ) ; req . onreadystatechange = function ( ) { var status ; if ( req . readyState === 4 ) { // DONE // remove the onreadystatechange handler, // because it could be called again // @NOTE: we replace it with a noop function, because // IE8 will throw an error if the value is not of type // 'function' when using ActiveXObject req . onreadystatechange = function ( ) { } ; try { status = req . status ; } catch ( e ) { // NOTE: IE (9?) throws an error when the request is aborted fail ( req ) ; return ; } // status is 0 for successful local file requests, so assume 200 if ( status === 0 && isRequestToLocalFile ( url ) ) { status = 200 ; } if ( isSuccessfulStatusCode ( status ) ) { success ( req ) ; } else { fail ( req ) ; } } } ; setHeaders ( req , headers ) ; // this needs to be after the open call and before the send call req . withCredentials = withCredentials ; req . send ( data ) ; return req ; }
Make an XHR request
@param   {string}   url              request URL
@param   {string}   method           request method
@param   {*}        data             request data to send
@param   {Array}    headers          request headers
@param   {boolean}  withCredentials  request withCredentials option
@param   {Function} success          success callback function
@param   {Function} fail             fail callback function
@returns {XMLHttpRequest}   Request object
@private
Make an XHR request