demos/Collage/fabric.js
function request(url, options) {

    options || (options = { });

    var method = options.method ? options.method.toUpperCase() : 'GET',
        onComplete = options.onComplete || function() { },
        request = makeXHR(),
        body;
        
    /** @ignore */
    request.onreadystatechange = function() {
      if (request.readyState === 4) {
        onComplete(request);
        request.onreadystatechange = emptyFn;
      }
    };
    
    if (method === 'GET') {
      body = null;
      if (typeof options.parameters == 'string') {
        url = addParamToUrl(url, options.parameters);
      }
    }

    request.open(method, url, true);
    
    if (method === 'POST' || method === 'PUT') {
      request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }

    request.send(body);
    return request;
  }
function request(url, options) {

    options || (options = { });

    var method = options.method ? options.method.toUpperCase() : 'GET',
        onComplete = options.onComplete || function() { },
        request = makeXHR(),
        body;
        
    /** @ignore */
    request.onreadystatechange = function() {
      if (request.readyState === 4) {
        onComplete(request);
        request.onreadystatechange = emptyFn;
      }
    };
    
    if (method === 'GET') {
      body = null;
      if (typeof options.parameters == 'string') {
        url = addParamToUrl(url, options.parameters);
      }
    }

    request.open(method, url, true);
    
    if (method === 'POST' || method === 'PUT') {
      request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }

    request.send(body);
    return request;
  }
function request ( url , options ) { options || ( options = { } ) ; var method = options . method ? options . method . toUpperCase ( ) : 'GET' , onComplete = options . onComplete || function ( ) { } , request = makeXHR ( ) , body ; /** @ignore */ request . onreadystatechange = function ( ) { if ( request . readyState === 4 ) { onComplete ( request ) ; request . onreadystatechange = emptyFn ; } } ; if ( method === 'GET' ) { body = null ; if ( typeof options . parameters == 'string' ) { url = addParamToUrl ( url , options . parameters ) ; } } request . open ( method , url , true ) ; if ( method === 'POST' || method === 'PUT' ) { request . setRequestHeader ( 'Content-Type' , 'application/x-www-form-urlencoded' ) ; } request . send ( body ) ; return request ; }
Cross-browser abstraction for sending XMLHttpRequest
@method request
@memberOf fabric.util
@param {String} url URL to send XMLHttpRequest to
@param {Object} [options] Options object
@param {String} [options.method="GET"]
@param {Function} options.onComplete Callback to invoke when request is completed
@return {XMLHttpRequest} request
Cross - browser abstraction for sending XMLHttpRequest