I have a system in which it takes information from the database. And this database is getting direct data, so I wanted to know how to get this data and display it on the page, but without this page being updated.
This system is in php.
I have a system in which it takes information from the database. And this database is getting direct data, so I wanted to know how to get this data and display it on the page, but without this page being updated.
This system is in php.
You'll need ajax for this, here's a minimalist example:
$.ajax({
url:'minha_pagina_acesso_banco.php', //sua página em php que retornará os dados
type:'POST', // método post, GET ...
data: 'param=1¶m2=2', //seus paramêtros
success: function(data){ // sucesso de retorno executar função
$('#result').html(data); // adiciona o resultado na div #result
}
});
You can perform this function according to user action, in a time interval, when loading the page and etc.
For more information on using jQuery.ajax ()
I recommend using GET in Jquery.
$.get("minha_pagina_acesso_banco.php",
function(data){
$('#result').html(data);
});
As you can see the code gets smaller, you can send and receive data like this.
The same syntax for post, if you want to send forms, just change the method.
$.post("minha_pagina_acesso_banco.php",
function(data){
$('#result').html(data);
});
Check out
In order not to reload the information every time the request is made, save the date of the last update in a PHP session variable, so that you change the screen every time you make the request. just echo the screen when the include / change date is different.
$.get("minha_pagina_acesso_banco.php",
function(data){
if(data!=''){
$("#result").html($("#result").html()+data);
}
});