blocks/bla/bla.js
function sendAjaxRequest(url, data, execOptions) {
            var xhr = new XMLHttpRequest();
            var d = vow.defer();
            xhr.onreadystatechange = function () {
                if (xhr.readyState === XMLHttpRequest.DONE) {
                    if (xhr.status === 200) {
                        d.resolve(JSON.parse(xhr.responseText));
                    } else {
                        d.reject(xhr);
                    }
                }
            };
            xhr.ontimeout = function () {
                d.reject(new ApiError(ApiError.TIMEOUT, 'Timeout was reached while waiting for ' + url));
                xhr.abort();
            };

            // shim for browsers which don't support timeout/ontimeout
            if (typeof xhr.timeout !== 'number' && execOptions.timeout) {
                var timeoutId = setTimeout(xhr.ontimeout.bind(xhr), execOptions.timeout);
                var oldHandler = xhr.onreadystatechange;
                xhr.onreadystatechange = function () {
                    if (xhr.readyState === XMLHttpRequest.DONE) {
                        clearTimeout(timeoutId);
                    }
                    oldHandler();
                };
            }

            xhr.open('POST', url, true);
            xhr.timeout = execOptions.timeout;
            xhr.setRequestHeader('Accept', 'application/json, text/javascript, */*; q=0.01');
            xhr.setRequestHeader('Content-type', 'application/json');
            xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
            xhr.send(data);

            return d.promise();
        }
function sendAjaxRequest(url, data, execOptions) {
            var xhr = new XMLHttpRequest();
            var d = vow.defer();
            xhr.onreadystatechange = function () {
                if (xhr.readyState === XMLHttpRequest.DONE) {
                    if (xhr.status === 200) {
                        d.resolve(JSON.parse(xhr.responseText));
                    } else {
                        d.reject(xhr);
                    }
                }
            };
            xhr.ontimeout = function () {
                d.reject(new ApiError(ApiError.TIMEOUT, 'Timeout was reached while waiting for ' + url));
                xhr.abort();
            };

            // shim for browsers which don't support timeout/ontimeout
            if (typeof xhr.timeout !== 'number' && execOptions.timeout) {
                var timeoutId = setTimeout(xhr.ontimeout.bind(xhr), execOptions.timeout);
                var oldHandler = xhr.onreadystatechange;
                xhr.onreadystatechange = function () {
                    if (xhr.readyState === XMLHttpRequest.DONE) {
                        clearTimeout(timeoutId);
                    }
                    oldHandler();
                };
            }

            xhr.open('POST', url, true);
            xhr.timeout = execOptions.timeout;
            xhr.setRequestHeader('Accept', 'application/json, text/javascript, */*; q=0.01');
            xhr.setRequestHeader('Content-type', 'application/json');
            xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
            xhr.send(data);

            return d.promise();
        }
function sendAjaxRequest ( url , data , execOptions ) { var xhr = new XMLHttpRequest ( ) ; var d = vow . defer ( ) ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState === XMLHttpRequest . DONE ) { if ( xhr . status === 200 ) { d . resolve ( JSON . parse ( xhr . responseText ) ) ; } else { d . reject ( xhr ) ; } } } ; xhr . ontimeout = function ( ) { d . reject ( new ApiError ( ApiError . TIMEOUT , 'Timeout was reached while waiting for ' + url ) ) ; xhr . abort ( ) ; } ; // shim for browsers which don't support timeout/ontimeout if ( typeof xhr . timeout !== 'number' && execOptions . timeout ) { var timeoutId = setTimeout ( xhr . ontimeout . bind ( xhr ) , execOptions . timeout ) ; var oldHandler = xhr . onreadystatechange ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState === XMLHttpRequest . DONE ) { clearTimeout ( timeoutId ) ; } oldHandler ( ) ; } ; } xhr . open ( 'POST' , url , true ) ; xhr . timeout = execOptions . timeout ; xhr . setRequestHeader ( 'Accept' , 'application/json, text/javascript, */*; q=0.01' ) ; xhr . setRequestHeader ( 'Content-type' , 'application/json' ) ; xhr . setRequestHeader ( 'X-Requested-With' , 'XMLHttpRequest' ) ; xhr . send ( data ) ; return d . promise ( ) ; }
Makes an ajax request.

@param {String} url A string containing the URL to which the request is sent.
@param {String} data Data to be sent to the server.
@param {Object} execOptions Exec-specific options.
@param {Number} execOptions.timeout Request timeout.
@returns {vow.Promise}
Makes an ajax request .