src/core/Ajax.js
function (url, options, cb) {
        if (isFunction(options)) {
            const t = cb;
            cb = options;
            options = t;
        }
        if (IS_NODE && Ajax.get.node) {
            return Ajax.get.node(url, cb, options);
        }
        const client = Ajax._getClient(cb);
        client.open('GET', url, true);
        if (options) {
            for (const k in options.headers) {
                client.setRequestHeader(k, options.headers[k]);
            }
            client.withCredentials = options.credentials === 'include';
            if (options['responseType']) {
                client.responseType = options['responseType'];
            }
        }
        client.send(null);
        return client;
    }
function (url, options, cb) {
        if (isFunction(options)) {
            const t = cb;
            cb = options;
            options = t;
        }
        if (IS_NODE && Ajax.get.node) {
            return Ajax.get.node(url, cb, options);
        }
        const client = Ajax._getClient(cb);
        client.open('GET', url, true);
        if (options) {
            for (const k in options.headers) {
                client.setRequestHeader(k, options.headers[k]);
            }
            client.withCredentials = options.credentials === 'include';
            if (options['responseType']) {
                client.responseType = options['responseType'];
            }
        }
        client.send(null);
        return client;
    }
function ( url , options , cb ) { if ( isFunction ( options ) ) { const t = cb ; cb = options ; options = t ; } if ( IS_NODE && Ajax . get . node ) { return Ajax . get . node ( url , cb , options ) ; } const client = Ajax . _getClient ( cb ) ; client . open ( 'GET' , url , true ) ; if ( options ) { for ( const k in options . headers ) { client . setRequestHeader ( k , options . headers [ k ] ) ; } client . withCredentials = options . credentials === 'include' ; if ( options [ 'responseType' ] ) { client . responseType = options [ 'responseType' ] ; } } client . send ( null ) ; return client ; }
Fetch remote resource by HTTP "GET" method
@param  {String}   url - resource url
@param  {Object}   [options=null] - request options
@param  {Object}   [options.headers=null] - HTTP headers
@param  {String}   [options.responseType=null] - responseType
@param  {String}   [options.credentials=null]  - if with credentials, set it to "include"
@param  {Function} cb  - callback function when completed
@return {Ajax}  Ajax
@example
maptalks.Ajax.get(
'url/to/resource',
(err, data) => {
if (err) {
throw new Error(err);
}
// do things with data
}
);
Fetch remote resource by HTTP GET method