Skip to content

Instantly share code, notes, and snippets.

@delba
Last active December 17, 2015 05:18
Show Gist options
  • Select an option

  • Save delba/5556813 to your computer and use it in GitHub Desktop.

Select an option

Save delba/5556813 to your computer and use it in GitHub Desktop.
Replacing current page with ajax response
xhr = new XMLHttpRequest
xhr.onreadystatechange = (e) ->
if @readyState is 4 and @status is 200
document.body.innerHTML = @responseXML.body.innerHTML
xhr.open 'GET', '/page'
xhr.responseType = 'document'
xhr.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment