Salve volevo sapere come si ricevere una variabile tramite ajax con il metodo post che nome viene attribuito al $_POST['qui che si mette io ho messo la chiave che si trova nel parametro data di ajax']?
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
</head>
<body>
<textarea width="200" height="300" id="commentoid" name="commento">
</textarea>
<button id="tastocommento">invia</button>
<div id="visualizza"></div>
<script type="text/javascript">
var commento = $("#commentoid").val();
$('button#tastocommento').click(function(){
$.ajax({
url:"commento.php",
type: "post",
data: 'commento=' + commento,
success:function(cacca){
$('#visualizza').html(cacca);
}
});
});
</script>
<iframe src="commento.php" width="400px;height="400px;>
</iframe>
</body>
</html>
il file commento.php
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>
<body>
ciaooooooooo
<?php
$commento=$_POST['commento'];//qui ricevo beneeeeeeeeeeeeeeeeeeeeeee?
echo $commento;
?>
</body>
</html>