Doubt about saving a data and updating a div right away

Asked

Viewed 49 times

-1

Good morning, everyone. Only with jQuery and Ajax I can insert a data into the database and then update a div on the page ?

Thank you.

  • Which database do you use? What do you use in the backend? Do you want to insert directly or submit a pro backend request and save the data from it?

  • I’m using mysql and java. The intention is for the person to post some doubt and when you click the post button it records in the database and then updates the div with the posts.

1 answer

0

Can, whenever you make a request ajax Voce will have a callback function, which will be executed when the request finishes and return something, in the case of ajax would be 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 via an id or class: $("#idDaDiv").html("oque colocar no conteúdo da div"); remembering that you use "#" in case you take the element by id and "." in case you take it by class. I hope I was clear.

Tip: always read the documentation -> http://api.jquery.com/jquery.ajax/

Browser other questions tagged

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