AJAX with jQuery not returning data

Posted by James P on Stack Overflow See other posts from Stack Overflow or by James P
Published on 2010-06-08T20:37:18Z Indexed on 2010/06/08 20:42 UTC
Read the original article Hit count: 162

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery