Skip to content

Instantly share code, notes, and snippets.

@maxgronlund
Created May 1, 2016 13:30
Show Gist options
  • Save maxgronlund/957f93c73c7d88b61728cfc0bb9766ae to your computer and use it in GitHub Desktop.
Save maxgronlund/957f93c73c7d88b61728cfc0bb9766ae to your computer and use it in GitHub Desktop.
$(".like-post").click(function() {
let csrf = document.querySelector("meta[name=csrf]").content;
let params = $(this).attr('value')
$.ajax({
url: "/like_posts",
type: "POST",
params: {like_post: params},
data: {
like_post: params
},
headers: {
"X-CSRF-TOKEN": csrf
},
dataType: "json",
success: function (data) {
console.log(data);
},
error: function (data) {
console.log(data);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment