function doGet(url, callback) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(e) { if (xhr.readyState === 4) { var resp = null; if (xhr.status === 200) { resp = xhr.response; try { resp = JSON.parse(/** @type {string} */ (resp)); } catch (e) { resp = null; } } callback(xhr.status, resp); } }; xhr.open('GET', url, true); xhr.send(null); }