Good morning everyone. Just with jQuery and Ajax I can insert a data into the database and then immediately update a div on the page?
Thank you.
Good morning everyone. Just with jQuery and Ajax I can insert a data into the database and then immediately update a div on the page?
Thank you.
You can, whenever you make an ajax request you will have a callback function, which will be executed when the request finishes and returns something, in case ajax would look something like this:
$.ajax({
url: 'url.do.serviço',
type: POST // metodo http a ser usado na requisição,
data: {algo_a_ser_enviado: dado_a_ser_salvo},
success: function(data){
// função de callback
}
in the callback function you can access the div by means of an id or class:
$("#idDaDiv").html("oque colocar no conteúdo da div");
remembering that you use "#" in case you get the element by the id and "." in case of picking up the class. I hope I have been clear.
Tip: Always read the documentation - > link