Skip to content

Instantly share code, notes, and snippets.

@tatey
Created September 16, 2013 05:42
Show Gist options
  • Save tatey/6577042 to your computer and use it in GitHub Desktop.
Save tatey/6577042 to your computer and use it in GitHub Desktop.
<!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>
@tatey
Copy link
Author

tatey commented Sep 16, 2013

Got to the CORS of the problem.

@davepies
Copy link

That is so hard-CORS!

@Jayphen
Copy link

Jayphen commented Sep 16, 2013

cor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment