Skip to content

Instantly share code, notes, and snippets.

@karan
Last active March 25, 2016 22:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save karan/68a45abbb49372164d38 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://code.jquery.com/jquery-2.2.2.min.js"></script>
</head>
<body>
<a class="btn btn-primary" id="agree_to_tos">Accept Terms of Service</a>
</body>
</html>
<script>
$('#agree_to_tos').click(function() {
$(function() {
$.ajax({
dataType: 'json',
contentType: "application/json",
type: 'PATCH',
data: JSON.stringify({'foo': 'bar'}),
headers: {
'Authorization': 'Bearer 123'
}
url: 'http://jsonplaceholder.typicode.com/posts/1',
success: function(data) {
console.log('SUCESS!!!!');
},
error: function (xhr, ajaxOptions, thrownError) {
console.log('FAILURE!!!!');
}
});
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment