lib/plugins/XMLHttpRequestPlugin.js
function sendRequest (async, url, config, callback) {
  var req = new XMLHttpRequest();
  req.open('GET', url, async);

  req.onerror = handleError;
  req.ontimeout = handleError;
  req.onload = handleResponse;

  setXHRConfig(req, config);

  req.send();

  function handleResponse () {
    var res = {
      status: getResponseStatus(req.status, url),
      headers: parseResponseHeaders(req.getAllResponseHeaders()),
      data: req.response || req.responseText,
    };

    if (res.status >= 200 && res.status < 300) {
      callback(null, res);
    }
    else if (res.status < 200 || res.status < 400) {
      callback(ono('Invalid/unsupported HTTP %d response', res.status));
    }
    else {
      callback(ono('HTTP %d error occurred (%s)', res.status, req.statusText));
    }
  }

  function handleError (err) {
    callback(err);
  }
}
function sendRequest (async, url, config, callback) {
  var req = new XMLHttpRequest();
  req.open('GET', url, async);

  req.onerror = handleError;
  req.ontimeout = handleError;
  req.onload = handleResponse;

  setXHRConfig(req, config);

  req.send();

  function handleResponse () {
    var res = {
      status: getResponseStatus(req.status, url),
      headers: parseResponseHeaders(req.getAllResponseHeaders()),
      data: req.response || req.responseText,
    };

    if (res.status >= 200 && res.status < 300) {
      callback(null, res);
    }
    else if (res.status < 200 || res.status < 400) {
      callback(ono('Invalid/unsupported HTTP %d response', res.status));
    }
    else {
      callback(ono('HTTP %d error occurred (%s)', res.status, req.statusText));
    }
  }

  function handleError (err) {
    callback(err);
  }
}
function sendRequest ( async , url , config , callback ) { var req = new XMLHttpRequest ( ) ; req . open ( 'GET' , url , async ) ; req . onerror = handleError ; req . ontimeout = handleError ; req . onload = handleResponse ; setXHRConfig ( req , config ) ; req . send ( ) ; function handleResponse ( ) { var res = { status : getResponseStatus ( req . status , url ) , headers : parseResponseHeaders ( req . getAllResponseHeaders ( ) ) , data : req . response || req . responseText , } ; if ( res . status >= 200 && res . status < 300 ) { callback ( null , res ) ; } else if ( res . status < 200 || res . status < 400 ) { callback ( ono ( 'Invalid/unsupported HTTP %d response' , res . status ) ) ; } else { callback ( ono ( 'HTTP %d error occurred (%s)' , res . status , req . statusText ) ) ; } } function handleError ( err ) { callback ( err ) ; } }
Sends an HTTP GET request using XMLHttpRequest.

@param {boolean} async - Whether to send the request synchronously or asynchronously
@param {string} url - The absolute URL to request
@param {Config} config - Configuration settings, such as timeout, headers, etc.
@param {function} callback - Called with an error or response object
Sends an HTTP GET request using XMLHttpRequest .