I am using python flask, I want the status of the button to change from "like" to liked when a user clicks it. I get no console errors, XHR loads perfectly. If I click the button and reload the page manually the status of the button changes, but I will like to do the reload with Ajax. Here is my code, thanks in advance. The backend returns a JSON object with jsonify.
HTML:
<button class="btn btn-pill btn-warning btn-xs" id="async_like">
<span class="icon icon-thumbs-up"></span> Like
jQuery:
<script>
$('button#async_like').click(function () {
$.ajax({
url :"{{ url_for('.like_post', id=post.id) }}",
type : 'POST',
success : function (resp) {
$('#async_like').append(resp);
}
})
})
</script>