【发布时间】:2015-12-27 05:00:58
【问题描述】:
我已经使用 Jquery、ajax 和 json 编写了前端简单的登录应用程序,我想将 json 信息发送到 php,它必须检索 json 的数据,如果成功则必须重定向到另一个页面,这是简单的我正在使用的前端代码。
!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="login.css">
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("#submit").on('click',function(){
var person={
user:$("#user").val(),
pass:$("#pass").val(),
}
$.ajax
({
type: "POST",
url: '/test/login.php',
dataType: 'json',
async: false,
data: person,
success: function () {
}
})
});
});
</script>
</head>
<body>
<div id="loginstyle">
<form action="login.php" method="post">
<table>
<tr>
<td>
Email:</td><td><input type="email" name="email" id="user" ></td>
<tr><td>Password:</td><td><input type="password" name="password" id="pass"><td></tr>
</table>
<input type="submit" value="submit" id="submit">
</div>
</form>
</body>
</html>
谁能建议我如何解码 json 数据并打印用户并传入 login.php
【问题讨论】: