-
-
Save vladkosinov/a49056008751edd8c456 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
}; | |
xhr.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment