Skip to content

Instantly share code, notes, and snippets.

function ajax(url, cb, errcb) {
var xhr;
xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (4 === xhr.readyState) {
if(xhr.status >= 200 && xhr.status < 400){
cb(xhr);
} else {
errcb(xhr);