0
I am reloading the page after entering a data in the bank via ajax, there is the possibility to update ( rebuild) only the table, or the div in which it is?
$(document).ready(function(){
$('#cadastrouser').hide();
$('#formcadastro').submit(function(event) {
// process the form
$.ajax({
type : 'POST', // define the type of HTTP verb we want to use (POST for our form)
url : 'cadastro.php', // the url where we want to POST
data : $("#formcadastro").serialize(), // our data object
dataType : 'json', // what type of data do we expect back from the server
encode : true
})
.done(function(data) {
var resdata = data;
if (resdata['sucesso']) {
location.reload();
}else{
alert(resdata['mensagem']);
}
});
event.preventDefault();
});
});
edits and inserts what is inside #formcadastro
– Leonardo Bonetti
You can manipulate the DOM and add in your table, put an ID on it to simplify see here: https://stackoverflow.com/questions/171027/add-table-row-in-jquery
– cmnardi
There’s no way to rebuild ?
– Igor Oliveira
just return the html for a call in a separate file or a specific treatment in your php to return only the piece that fills the table, and then replace the html of the div. There are many ways to do it that you are wanting.
– Zorkind