Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Last active September 3, 2017 16:38
Show Gist options
  • Save khaosdoctor/9c043cf935e07a7ba214ecde82b82faf to your computer and use it in GitHub Desktop.
Save khaosdoctor/9c043cf935e07a7ba214ecde82b82faf to your computer and use it in GitHub Desktop.
var counter = 0
function ajax() {
let xhr = new XMLHttpRequest()
// Abre a conexão para a página
xhr.open(‘GET’, ‘<URL>’)
xhr.onreadystatechange = () => {
counter += 20 // 20% pois são 5 estados
if (xhr.readystate === 4 && xhr.status === 200) {
console.log(xhr.responseText) // Aqui você tem sua resposta
}
})
xhr.send()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment