Inverse-Rezeptsuche/app/application/static/coms.js

15 lines
354 B
JavaScript

function getJSON(url, callback, fallback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function () {
var status = xhr.status;
if (status < 400) {
callback(null, xhr.response);
} else {
fallback();
}
};
xhr.send();
};