index.html内容如下
ul{
list-style: none;
}
User Login
- Username
- Password
$(document).ready(function(){
$("#ajaxBtn").click(function(){
$.ajax({
'type':'get',
'url':'index.php',
'dateType':'json',
'data':$("input").serialize(),
'success':function(res){
console.log(res);
}
});
});
});
index.php内容如下
header("Content-type:text/html;charset=utf-8");
$username = $_GET['username'];
$password = $_GET['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);