Created
July 11, 2016 11:42
-
-
Save Tam/8aa62059146c4d95a3503b859aaa0da9 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 get(url, success, error) { | |
var request = new XMLHttpRequest(); | |
request.open('GET', window.baseUrl + url, true); | |
request.setRequestHeader("X-Requested-With", "XMLHttpRequest"); | |
request.onload = function() { | |
var data = request.responseText; | |
if (request.status >= 200 && request.status < 400) { | |
success(data); | |
} else { | |
error(data); | |
} | |
}; | |
request.onerror = function () { | |
error(); | |
}; | |
request.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment