views:

50

answers:

1

I tried to just send some information to a php file using Jquery Ajax. I wanted to send some info to the php file every time a click is made.

<script>
    $(document).ready(function() {
        $('#checkbox').click(function() {
        $.ajax({type : "POST",
            url : "test.php",
            data : "ffs=somedata&ffs2=somedata2",
            succes : function() {
                alert("something");
            } 
        });
        });
    });
</script>
<body>
        <input type = "checkbox" name = "checkbox" id = "checkbox">
</body>

The php file looks like this:

<?php

echo $_POST['ffs'];

?>  

Now, I see the POST going, (using firebug). I get no errors, but nothing happens in the php file. Also success is never reached, so no alert is triggered. What should I do in the php file so that I can trigger success and also see the sent info?

+1  A: 

Typo, change

succes : function() {

to

success : function() {

And to retrieve the response from the PHP use

success : function(data) {
    alert(data);
}

For more info see this

BrunoLM
Yeah, that's it. Thanks.
vladv