p5.js-web-editor/static/loadData.js

19 lines
517 B
JavaScript
Raw Normal View History

2016-08-15 22:06:09 +00:00
var allData;
function fetchJSONFile(path, callback) {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200) {
var data = JSON.parse(httpRequest.responseText);
if (callback) callback(data);
}
}
};
httpRequest.open('GET', path,false);
httpRequest.send();
}
2016-08-19 16:44:44 +00:00
fetchJSONFile('data.min.json', function(data){
allData = data;
2016-08-15 22:06:09 +00:00
});