HTML页面
<html>
<head>
</head>
<body>
<form action="7.php">
<input type="text" name="name">
<input type="text" name="pass">
<input type="text" name="age">
<input type="button" value="提交" onclick="a();">
</form>
<script class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="js\jquery-1.11.2.min.js"></script>
<script>
function a(){
var cont=$("input").serialize();
$.ajax({
url:"7.php",
type:'post',
data:cont,
success:function (data){
var res = eval("(" + data + ")");//转为Object对象
document.write("name:"+res["name"]+"<br>");
document.write("pass:"+res["pass"]+"<br>");
document.write("age:"+res["age"]+"<br>");
}
})
}
</script>
</body>
</html>
PHP页面
<?php
$name=$_POST["name"];
$pass=$_POST["pass"];
$age=$_POST["age"];
$arr=array("name"=>$name,"pass"=>$pass,"age"=>$age);
$arr=json_encode($arr);
echo $arr;
?>
共同学习,写下你的评论
评论加载中...
作者其他优质文章