Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created September 3, 2017 16:39
Show Gist options
  • Save khaosdoctor/4828725ba7dcc251923b7d8d743ab963 to your computer and use it in GitHub Desktop.
Save khaosdoctor/4828725ba7dcc251923b7d8d743ab963 to your computer and use it in GitHub Desktop.
var request = new XMLHttpRequest();
request.open(‘GET’, ‘/my/url’, true);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
// Sucesso!
var resp = this.response;
} else {
// Alcançamos o servidor, mas tivemos um erro
}
};
request.onerror = function() {
// Erro de conexão
};
request.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment