I'm trying to load a simple success or failure message from the server upon submission. I am reaching success on the Ajax call. However $('#some_div').html(data) is having the whole originating page being returned to it. Is there something I'm missing?
$(document).ready(function() {
$('a.favorite').click(function() {
var song_id = $(this).attr("id");
$.ajax({
url: 'ajax_favorite.php?song_id=' + song_id,
success: function(data, textStatus, req) {
$('#add_to_favorite_'+song_id).html(data);
},
error: function(req) { // req = XMLHttpRequest object
alert("could not reach the server");
}
});
return false;
});
});
update: the code on the ajax_favorite.php?song_id=745 page is
<?php
echo "blah blah";
?>