With this code using ajax that I will show below, you will not have refresh on your page, but your button will have to be type=submit and will also have to add a class within your tag <form>. Follow the code not to do refresh and then how will you have to leave your <form> To class is useful, because if you want to create other forms with this script will have the possibility, already with ID no, yeah ID is unique
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('ajax').submit(function(){
var dados = $( this ).serialize();
$.ajax({
type: "POST",
url: "nomedoarquivo.php",
data: dados,
success: function( data )
{
alert( data );
}
});
return false;
});
});
</script>
How would you have to change your <form>, don’t worry about leaving it without action=nomedoarquivo.php and without method='POST' after all, I have already indicated this in the above script
<form action='' method='' class='ajax'>
your update button, is of type=Submit ?
– Victor
Yeah, like a Ubmit!
– olifreitas
Possible duplicate of To send string variables as parameter to call Ajax?
– Sam