Jquery Mobile+php 提交表单及后台接收跳转问题

IF先生 2020-07-20 04:00:19
刚开始学想JqueryMobile,用JqueryMobile + PHP做个移动端,一开始做登陆页面就遇到表单提交问题,怎样提交都没有反应也不会跳转!
请各位大神解惑!

前端提交表单代码


<body>

<div data-role="page" id="login">
<div data-role="header">
<h1>用戶登入</h1>
</div>
<div data-role="content">
<form id="form1" name="form1" method="post" action="#">
<div data-role="fieldcontain">
<input type="text" name="username" id="username" placeholder="用戶名">
<input type="password" name="password" id="password" placeholder="密碼">
<input type="submit" data-role="button" id="submit" value="登入" onClick="ajax_login()">
</div>
</form>
<p>沒有帳號?<a href="#register" data-transition="slide">點擊註冊</a></p>
</div>

<div data-role="footer" style="text-align: center" data-position="fixed">
<p>CopyRight ©2020</p>
</div>
</div>

<script>
function ajax_login() {
var username = $("#username").val();
var password = $("#password").val();
var urlweb = "loading_check.php";

if (username==""){
layer.open({content: '請輸入用戶名!',btn: '好的'});
document.getElementById("username").focus();
return false;
}
if (password==""){
layer.open({content: '請輸入密碼!',btn: '好的'});
document.getElementById("password").focus();
return false;
}

$.ajax({
type: "POST",
url: urlweb,
dataType:'json',
data: {user:username,pass:password},
beforeSend: function () {
document.getElementById("submit").value = "正在登入中";
},
success: function (json) {
if(json.Loge==3){
document.getElementById("submit").value = "登入成功";
window.self.location='admin/input.html';
}else if(json.Loge==1){
layer.open({content: '帳戶名錯誤',skin: 'footer'});
document.getElementById("txtname").focus();
document.getElementById("submit").value = "重新登入";
}
}
});
}

</script>

</body>



后台PHP接收处返回信息

include("conn/conn.php");
$user=$_REQUEST['username'];
$pass=md5($_REQUEST['password']);
$sql = mysql_query("select * from user where Nmber='".$user."' and Pass='".$pass."' ");
if($result = mysql_fetch_array($sql)){

echo json_encode(array ('Loge'=>3));
}else{
echo json_encode(array ('Loge'=>1));

}

...全文
137 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
下雨的声音丶 2020-07-20
  • 打赏
  • 举报
回复
打开浏览器调试器 看一下是否有网络请求,再来看问题
kkkwadu 2020-07-20
  • 打赏
  • 举报
回复
断点测试一下,传到php没有

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧