Scusate, ho trovato questo: dovrebbe essere giusto ma non mi appare nulla, mi aiutate please?
Inserendo degli alert, ho verificato che entra nella funzione click e nel file php, ma non appare nulla nel div.
codice:
$("#bottone").click(function(){
var nome1= $("select#sel1 option:selected").val();
var nome2= $("select#sel2 option:selected").val();
var nome3= $("select#sel3 option:selected").val();
var nome4= $("select#sel4 option:selected").val();
var nome5= $("select#sel5 option:selected").val();
var nome6= $("select#sel6 option:selected").val();
var nome7= $("select#sel7 option:selected").val();
$.ajax({
type: "POST",
url: "dati.php",
data: nome1+nome2+nome3+nome4+nome5+nome6+nome7,
dataType: "html",
success: function(msg)
{
$("#risultato").html(msg);
},
error: function()
{
alert("Chiamata fallita, si prega di riprovare...");
}
});
});
codice:
<body>
<input name="bottone" type="button" id="bottone" value="invia" >
<div id="risultato">
</body>
file dati.php
codice:
<?PHP
$co=$_POST['nome1'];
$p=$_POST['nome2'];
$c=$_POST['nome3'];
$q=$_POST['nome4'];
$t=$_POST['nome5'];
$pr=$_POST['nome6'];
$m=$_POST['nome7'];
?>