标签:username 姓名 array 实例 cli user charset ade url
//网站 http://www.cnblogs.com/hjxcode/p/6029781.html
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
$("#send").click(function(){
var cont = $("input").serialize();
$.ajax({
url:‘ab.php‘,
type:‘post‘,
dataType:‘json‘,
data:cont,
success:function(data){
var str = data.username + data.age + data.job;
$("#result").html(str);
}
});
});
});
</script>
</head>
<body>
<div id="result">一会看显示结果</div>
<form id="my" action="" method="post">
<p><span>姓名:</span><input type="text" name="username" /></p>
<p><span>年龄:</span><input type="text" name="age" /></p>
<p><span>工作:</span><input type="text" name="job" /></p>
</form>
<button id="send">提交</button>
</body>
</html>
//php
<?php
header("Content-type:text/html;charset=utf-8");
$username = $_POST[‘username‘];
$age = $_POST[‘age‘];
$job = $_POST[‘job‘];
$json_arr = array("username"=>$username,"age"=>$age,"job"=>$job);
标签:username 姓名 array 实例 cli user charset ade url
原文地址:https://www.cnblogs.com/stay29/p/9215490.html