ker/mod/tfw.web-service.js
function loadJSON( path ) {
    return new Promise( function( resolve, reject ) {
        var xhr = new XMLHttpRequest( {
            mozSystem: true
        } );
        xhr.onload = function() {
            var text = xhr.responseText;
            try {
                resolve( JSON.parse( text ) );
            } catch ( ex ) {
                reject( Error( "Bad JSON format for \"" + path + "\"!\n" + ex + "\n" + text ) );
            }
        };
        xhr.onerror = function() {
            reject( Error( "Unable to load file \"" + path + "\"!\n" + xhr.statusText ) );
        };
        xhr.open( "GET", path, true );
        xhr.withCredentials = true; // Indispensable pour le CORS.
        xhr.send();
    } );
}
function loadJSON( path ) {
    return new Promise( function( resolve, reject ) {
        var xhr = new XMLHttpRequest( {
            mozSystem: true
        } );
        xhr.onload = function() {
            var text = xhr.responseText;
            try {
                resolve( JSON.parse( text ) );
            } catch ( ex ) {
                reject( Error( "Bad JSON format for \"" + path + "\"!\n" + ex + "\n" + text ) );
            }
        };
        xhr.onerror = function() {
            reject( Error( "Unable to load file \"" + path + "\"!\n" + xhr.statusText ) );
        };
        xhr.open( "GET", path, true );
        xhr.withCredentials = true; // Indispensable pour le CORS.
        xhr.send();
    } );
}
function loadJSON ( path ) { return new Promise ( function ( resolve , reject ) { var xhr = new XMLHttpRequest ( { mozSystem : true } ) ; xhr . onload = function ( ) { var text = xhr . responseText ; try { resolve ( JSON . parse ( text ) ) ; } catch ( ex ) { reject ( Error ( "Bad JSON format for \"" + path + "\"!\n" + ex + "\n" + text ) ) ; } } ; xhr . onerror = function ( ) { reject ( Error ( "Unable to load file \"" + path + "\"!\n" + xhr . statusText ) ) ; } ; xhr . open ( "GET" , path , true ) ; xhr . withCredentials = true ; // Indispensable pour le CORS. xhr . send ( ) ; } ) ; }
Load a JSON file and return a Promise.
@param {string} path Local path relative to the current HTML page.
Load a JSON file and return a Promise .