How to update a DIV with PHP

Asked

Viewed 754 times

1

Hello, I read some tutorials on how to update every few seconds(using javascript, Jquery, etc) and wanted to know if there is a way to update a DIV with PHP itself, when pressing a button for example.

For example, when doing a survey update a specific DIV within the site without updating the entire page.

3 answers

1


$('#botao').click(function(){ 
    $.ajax({
            type      : 'post', 
            url       : 'teste.php', 
            data      : 'nome='+ $('#campo1').val() +'&sobrenome='+ $('#campo2').val(), 
            dataType  : 'html', 
            success : function(resultado){
                    $('#tabela').html(resultado);
                }
        }); 
});

0

It is not possible, for this you need a client-side language like javascript. If you only use PHP you can build the updated page and send the whole page to the client again.

0

AJAX + jQuery

Function load()

With PHP there is no way because it is a language that works on the server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.