Skip to content

Instantly share code, notes, and snippets.

@0i0
Created November 24, 2012 17:10
Show Gist options
  • Save 0i0/4140557 to your computer and use it in GitHub Desktop.
Save 0i0/4140557 to your computer and use it in GitHub Desktop.
Short Ajax
var xhr = new XMLHttpRequest()
var url = 'http://'
xhr.open("GET",url,false)
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8")
xhr.send(null)
if (xhr.status==200){
var data = JSON.parse(xhr.responseText)
console.log(data)
} else {
console.log('error')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment