87,993
社区成员
发帖
与我相关
我的任务
分享
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" charset="utf8" src="https://csdnimg.cn/public/common/libs/jquery/jquery-1.11.1.min.js"></script>
<title>Document</title>
</head>
<body>
<script>
$(function() {
$.ajax({
url:'queryOK2.php',
dataType:"json",
type:"POST",
data:{"keyword":"csdn","id":"10086"},
async:false,
success:function(json) {
console.log(json);
}
});
});
</script>
</body>
</html>
$(function() {
$.ajax({
url:'queryOK2.php',
dataType:"json",
type:"POST",
data:{"keyword":"csdn","id":"10086"},
async:false,
success:function(json) {
console.log(json);
//这里会输出[{keyword: "csdn", id: "10086"}]
}
});
});
<?php
header("Content-type: text/html; charset=UTF-8");
$keyword = trim($_POST['keyword']);
$id= trim($_POST['id']);
$data = array();
$data[0]=array(
"keyword"=>$keyword,
"id"=>$id
);
echo json_encode($data);
?>