To send data without your page updating, refresh or something like that. It is necessary to use javascript with a serialize .
<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>
But for that you will have to change your tag form, in case it is like this
<form action="nomedoarquivo.php" method="POST">
You should leave so, as I will show below, after all in Javascript will already be indicating the file name and the sending method that will be POST
<form action="" method="" id="ajax">
Remembering that in this case should have a Submit to work the sending of data correctly, I will give an example below a Submit
<input type="submit" value="Salvar informações">
You can do this using javascript, but you have some code implemented ?
– Victor
i have a code, but I don’t know how to do this function with pure js. if you know some way, pf help me
– Gustavo Bessa
Edit the question and put your code if possible or part of it, but the question is, you’re using Submit in your form?
– Victor
i still don’t have a code of that function ... before that I was passing the JS variables to PHP and sending to the bank.
– Gustavo Bessa
Do what I will tell you I tested and it worked here and me a feedback, if positive mark the answer as best so that other users understand that this answer will resolve their doubt. It can help other users in the future
– Victor