Created
December 21, 2015 11:45
-
-
Save JiLiZART/dc6e126e4779b9a356bd 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
<div class="js-favorite"> | |
<a href="/favoriteActionWithAjaxSupport" class="js-favorite-link">Favorite</a> | |
</div> |
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
//гденибудь на сайте | |
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