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 you will also have to add class
inside your% with%. Follow the code to not refresh and then as you will have to leave your <form>
a <form>
is useful, because if you want to create other class
with this script you will have the possibility, already with forms
no, therefore ID
is unique
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><scripttype="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>
As you would have to change your ID
, do not worry about leaving it without <form>
and without action=nomedoarquivo.php
after all, I already indicated this in the script above
<form action='' method='' class='ajax'>