I am creating a tumblr theme, I added a like button to ever post. This is a sample url:
<a class="loveit" href="http://www.tumblr.com/like/fGKvAJgQ?id=16664837215">like it</a>
This works perfectly. However, the result is just a blank page, so I need a way to trigger the link without a page refresh.
At the moment I am trying this code:
$('.loveit').click(function(e){
e.preventDefault();
var targetUrl = $(this).attr('href');
$.ajax({
url: targetUrl,
type: "GET",
success:function(){
alert("done");
},
error:function (){
alert("testing error");
},
});
});
But it does not work. How can this link run without refreshing the existing page?
Thanks