Using the AJAX
of JQUERY
:
First of all you need the linked JQUERY library in your script like this:
<script src='jquery.js' type='text/javascript'></script>
Imagine you have this form in your index.php
:
<form>
<input id="dado1" type="text">
<input id="dado2" type="text">
<input id="enviar" type="submit">
</form>
When you click submit, ajax will send input values to the page armazenaDados.php
<script>
$('#enviar').on('click',function(){
var dado1 = $('#dado1').val();
var dado2 = $('#dado2').val();
$.ajax({
url: 'armazenaDados.php',
type: 'POST',
data: { dadoA: dado1, dadoB: dado2 },
success: function(data) {
alert("alterado!");
}
});
});
</script>
In the archive armazenaDados.php
you recover these values:
<?php
$dado1 = $_POST['dadoA'];
$dado2 = $_POST['dadoB'];
.... código que armazena os dados...
You tried using jquery json?
– Andrei Coelho
I don’t know it like it is?
– Andressa Limão
I will formulate an example answer
– Andrei Coelho
I said Json, but it’s actually AJAX. Sleep is already beating...
– Andrei Coelho
Take a tour so you get better results in your questions. https://answall.com/help/mcve. takes advantage of this post to also https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079
– user60252