加载json(注意跨域) a. 1 2 3 4 5 6 7 fetch(jsonurl) .then(function(response) { return response.json(); }) .then(function(myjson) { console.log(json.stringify(myjson)); }); b. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 var getJSON = function(url, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'json';
Read more...