I have a little problem that I tried to solve without success and I hope you guys could help me .
So I have a button that once clicked should call an Ajax function and replace itself with the response gotten from the Ajax on success .
My code so far for the html :
<div class="btn-group">
<button id="button1" class="btn btn-white btn-xs" onclick="like(83,1)">
<i class="fa fa-heart-o"></i>
 J'aime !
</button>
</div>
and the jquery part :
function like(id, t) {
    $.ajax({
        type: "GET",
        url: "ajax/likes.php?postID=" + id + "&likeID=" + t,
        dataType: 'html',
        success: function(data) {
            $("#button" + t).replaceWith(data);
        }
    });
}
Clicking & calling the Ajax function works and I can see the response with the required HTML from the developer console but the original one doesn't get replaced with it .
The response looks like that :
<button id='button1' class='btn btn-white btn-xs 1' onclick='like(83,1)'>
<i class='fa fa-heart'></i>
 J'aime plus         
</button>
Thanks !
 
     
     
     
    