日期:2014-05-16 浏览次数:20578 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="conent-type" content="text/html; charset=utf-8">
<title> client post</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<script type="text/javascript">
function fsubmit(){
$.post("server.php", { username: $("#username").val(), password: $("#password").val() },function(ret){
if(ret.success==true){
alert('login success');
}else{
alert('login fail');
}
},'json');
}
</script>
<p>username:<input type="text" id="username"></p>
<p>password:<input type="text" id="password"></p>
<p><input type="button" value="submit" onclick="fsubmit()"></p>
</body>
</html>
<?php
$username = isset($_POST['username'])? $_POST['username'] : '';
$password = isset($_POST['password'])? $_POST['password'] : '';
$ret = array();
if($username=='fdipzone' && $password=='123456'){
$ret['success'] = true;
}else{
$ret['success'] = false;
}
echo json_encode($ret);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script
&nbs