Skip to content

Instantly share code, notes, and snippets.

@JiLiZART
Created December 21, 2015 11:45
Show Gist options
  • Save JiLiZART/dc6e126e4779b9a356bd to your computer and use it in GitHub Desktop.
Save JiLiZART/dc6e126e4779b9a356bd to your computer and use it in GitHub Desktop.
<div class="js-favorite">
<a href="/favoriteActionWithAjaxSupport" class="js-favorite-link">Favorite</a>
</div>
//гденибудь на сайте
var CSRF = {
'_csrf': $('meta[name="csrf-token"]').attr("content")
};
//favorite.js
$('.js-favorite').on('click', 'a.js-favorite-link', function(e) {
$.post($(this).attr('href'), CSRF, function(response) {
if (response.status) {
$(e.delegateTarget).html(response.html);
}
});
e.preventDefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment