前台javascript代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script>
$(function(){
var v="变量";
v=escape(v)+"";//编码,防止汉字乱码
$.ajax({
url: "php_ajax.php",
type: "POST",
data:{v1:v},
//dataType: "json",
error: function(){
alert('Error loading XML document');
},
success: function(data,status){//如果调用php成功
alert(unescape(data));//解码,显示汉字
}
});
});
</script>
后台php代码
<?php
$v1=$_POST['v1'];
echo $v1."+后台返回";
?>