dist/crocodoc.viewer.js
function (url, options) {
            var opt = parseOptions(options),
                method = opt.method,
                data = opt.data,
                headers = opt.headers,
                withCredentials = opt.withCredentials;

            if (method === 'GET' && data) {
                url = urlUtil.appendQueryParams(url, data);
                data = '';
            }

            /**
             * Function to call on successful AJAX request
             * @returns {void}
             * @private
             */
            function ajaxSuccess(req) {
                if (util.isFn(opt.success)) {
                    opt.success.call(createRequestWrapper(req));
                }
                return req;
            }

            /**
             * Function to call on failed AJAX request
             * @returns {void}
             * @private
             */
            function ajaxFail(req) {
                if (util.isFn(opt.fail)) {
                    opt.fail.call(createRequestWrapper(req));
                }
                return req;
            }

            // is XHR supported at all?
            if (!support.isXHRSupported()) {
                return opt.fail({
                    status: 0,
                    statusText: 'AJAX not supported'
                });
            }

            // cross-domain request? check if CORS is supported...
            if (urlUtil.isCrossDomain(url) && !support.isCORSSupported()) {
                // the browser supports XHR, but not XHR+CORS, so (try to) use XDR
                return doXDR(url, method, data, ajaxSuccess, ajaxFail);
            } else {
                // the browser supports XHR and XHR+CORS, so just do a regular XHR
                return doXHR(url, method, data, headers, withCredentials, ajaxSuccess, ajaxFail);
            }
        }
function (url, options) {
            var opt = parseOptions(options),
                method = opt.method,
                data = opt.data,
                headers = opt.headers,
                withCredentials = opt.withCredentials;

            if (method === 'GET' && data) {
                url = urlUtil.appendQueryParams(url, data);
                data = '';
            }

            /**
             * Function to call on successful AJAX request
             * @returns {void}
             * @private
             */
            function ajaxSuccess(req) {
                if (util.isFn(opt.success)) {
                    opt.success.call(createRequestWrapper(req));
                }
                return req;
            }

            /**
             * Function to call on failed AJAX request
             * @returns {void}
             * @private
             */
            function ajaxFail(req) {
                if (util.isFn(opt.fail)) {
                    opt.fail.call(createRequestWrapper(req));
                }
                return req;
            }

            // is XHR supported at all?
            if (!support.isXHRSupported()) {
                return opt.fail({
                    status: 0,
                    statusText: 'AJAX not supported'
                });
            }

            // cross-domain request? check if CORS is supported...
            if (urlUtil.isCrossDomain(url) && !support.isCORSSupported()) {
                // the browser supports XHR, but not XHR+CORS, so (try to) use XDR
                return doXDR(url, method, data, ajaxSuccess, ajaxFail);
            } else {
                // the browser supports XHR and XHR+CORS, so just do a regular XHR
                return doXHR(url, method, data, headers, withCredentials, ajaxSuccess, ajaxFail);
            }
        }
function ( url , options ) { var opt = parseOptions ( options ) , method = opt . method , data = opt . data , headers = opt . headers , withCredentials = opt . withCredentials ; if ( method === 'GET' && data ) { url = urlUtil . appendQueryParams ( url , data ) ; data = '' ; } /**
             * Function to call on successful AJAX request
             * @returns {void}
             * @private
             */ function ajaxSuccess ( req ) { if ( util . isFn ( opt . success ) ) { opt . success . call ( createRequestWrapper ( req ) ) ; } return req ; } /**
             * Function to call on failed AJAX request
             * @returns {void}
             * @private
             */ function ajaxFail ( req ) { if ( util . isFn ( opt . fail ) ) { opt . fail . call ( createRequestWrapper ( req ) ) ; } return req ; } // is XHR supported at all? if ( ! support . isXHRSupported ( ) ) { return opt . fail ( { status : 0 , statusText : 'AJAX not supported' } ) ; } // cross-domain request? check if CORS is supported... if ( urlUtil . isCrossDomain ( url ) && ! support . isCORSSupported ( ) ) { // the browser supports XHR, but not XHR+CORS, so (try to) use XDR return doXDR ( url , method , data , ajaxSuccess , ajaxFail ) ; } else { // the browser supports XHR and XHR+CORS, so just do a regular XHR return doXHR ( url , method , data , headers , withCredentials , ajaxSuccess , ajaxFail ) ; } }
Make a raw AJAX request
@param   {string}     url               request URL
@param   {Object}     [options]         AJAX request options
@param   {string}     [options.method]  request method, eg. 'GET', 'POST' (defaults to 'GET')
@param   {Array}      [options.headers] request headers (defaults to [])
@param   {*}          [options.data]    request data to send (defaults to null)
@param   {Function}   [options.success] success callback function
@param   {Function}   [options.fail]    fail callback function
@returns {XMLHttpRequest|XDomainRequest} Request object
Make a raw AJAX request