index.html内容如下:
ul{
list-style: none;
}
User Login
- Username
- Password
$(document).ready(function(){
$("#ajaxBtn").click(function(){
$.post("index.php",$(".ipt-style").serialize(),function(res){
console.log(res);
});
});
});
index.php内容如下:
header("Content-type:text/html;charset=utf-8");
$username = $_POST['username'];
$password = $_POST['password'];
$res = array('code'=>1,'msg'=>'','data'=>[]);
if($username == 'ceshi' && $password == '123456'){
$res['msg'] = "success";
}else{
$res['code'] = 0;
$res['msg'] = 'fail';
}
echo json_encode($res);