Created
July 13, 2015 20:02
-
-
Save jsha/928a5b3c0ff352a1cd0f to your computer and use it in GitHub Desktop.
Demonstration of cookie availability in XHR callback.
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
cookie: <div id=cookie> </div> | |
<? setcookie('c', rand()) ?> | |
<script type="text/javascript" > | |
function reqListener () { | |
console.log(document.cookie); | |
document.getElementById('cookie').innerHTML = document.cookie; | |
} | |
function fetch() { | |
var oReq = new XMLHttpRequest(); | |
oReq.onload = reqListener; | |
oReq.open("get", "", true); | |
oReq.send(); | |
} | |
setInterval(fetch, 1000); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment