Created
September 16, 2013 05:42
-
-
Save tatey/6577042 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<!DOCTYPE> | |
<html> | |
<head> | |
</head> | |
<body> | |
<a id="btn" href="#">Create Comment</a> | |
<script type="text/javascript"> | |
var btn = document.querySelector('#btn'); | |
btn.addEventListener('click', function(e) { | |
xhr = new XMLHttpRequest(); | |
xhr.withCredentials = true; | |
xhr.onload = function(e) { | |
console.log(e); | |
}; | |
xhr.open('POST', 'http://localhost:3000/api/plans/25/comments?format=json', true); | |
xhr.setRequestHeader("Content-Type", "application/json"); | |
xhr.send('{"body": "Hey"}'); | |
e.preventDefault(); | |
}); | |
</script> | |
</body> | |
</html> |
That is so hard-CORS!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got to the CORS of the problem.