Pregunta

Here is the code for the jquery:

<script type="text/javascript"> 
    $(document).ready(function(){
        $('#room').submit(function(){
            $.post('backend/CreateRoom.php', $('#room').serialize() ,function(data) {
                alert(1);
                $('#llama').append(data);
                console.log('working');
            });
        });
        return false;
     }); 
</script>

The function part does not seem to be working. The PHP code on the backend/CreateRoom.php seems to work fine(the code updates a PHP database) works fine, it just doesnt update the div, or do anything I put in the function. Help?

¿Fue útil?

Solución

Looks like you are returning false on document ready. I think you want that on submit.

$(document).ready(function(){
    $('#room').submit(function(){
        $.post('backend/CreateRoom.php', $('#room').serialize() ,function(data) {
            alert(1);
            $('#llama').append(data);
            console.log('working');
        });
     return false;
    });

});

or prevent default:

$(document).ready(function(){
    $('#room').submit(function(event){
        event.preventDefault();
        $.post('backend/CreateRoom.php', $('#room').serialize() ,function(data) {
            alert(1);
            $('#llama').append(data);
            console.log('working');
        });
    });
});
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top