AJAX with jQuery not returning data
- by James P
This is my Javascript:
$(document).ready(function() {
$('#like').bind('keydown', function(e) {
if(e.keyCode == 13) {
var likeMsg = $('#like').val();
if(likeMsg) {
// Send the AJAX request to like.php
$.ajax({
url: 'like.php',
success: function(data) {
alert('Content: ' + data);
}
});
}
}
});
});
And this is my like.php file:
<?php
echo "It works! :)";
?>
When I press enter on the #like input, it seems the AJAX request is sent and an alert box comes up saying: Content:, but there's no data being sent back from like.php...
I have checked if the file exists and if it's in the same directory and whatever and it is, so I'm pretty much clueless atm.
Does anyone know what could be wrong here? Cheers.