Heim > Fragen und Antworten > Hauptteil
Ich habe alle Laui-Dateien importiert, aber die jS-Datei kann nicht geladen werden. Ich habe die Pfade überprüft und sie sind genau die gleichen wie bei Ihnen.
L2019-06-16 23:40:26
{username:$('#username').val(),pwd:$('#pwd').val(),verifycode:$('#verifycode').val()}
不不,应该这样,还要把单引号去掉
L2019-06-16 23:33:45
{'username':$('#username').val(),'pwd':$('#pwd').val(),'verifycode':$('#verifycode').val()}
试试这样应该可以
A天罡星2019-06-15 11:49:34
我的本地路径D:\PHPTutorial\WWW\qiyu\public\static\plugins\layui
代码如下
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>登录</title>
<link type="text/css" href="__STATIC__/plugins/layui/css/layui.css" rel="stylesheet"/>
<script type="text/javescript" src="__STATIC__/plugins/layui/layui.js"></script>
</head>
<body style="background:#0ed8da">
<div style="position: absolute;left:50%;top:50%;width:500px;margin-left:-250px;margin-top:-200px">
<div style="background:#fdfdfd;padding: 20px;border-radius:4px;box-shadow: 5px 5px 20px #444444">
<div class="layui-form">
<div class="layui-form-item" style="color:grey">
<h1>后胎管理系统<h1>
</div>
<hr>
<div class="layui-form-item">
<label class="layui-form-label">用户名</label>
<div class="layui-input-block">
<input type="text" id='username' class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<input type="password" id='password' class="layui-input">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">验证码</label>
<div class="layui-input-inline">
<input type="text" id='verifycode' class="layui-input">
</div>
<img id="code" src="{:captcha_src()}" onclick="this.src=this.src+'?'+Math.random()"/>
</div>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" onclick="dologin()">登录</button>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
layui.use(['layer'],function(){
$=layui.juqery;
layer=layui.layer;
});
function dologin(){
var username=$.trim($('#username').val());
var pwd=$.trim($('#password').val());
var verifycode=$.trim($('#verifycode').val());
if(username==''){
layer.alert('请输入用户名',{icon:2});
return;
}
if(pwd==''){
layer.alert('请输入密码',{icon:2});
return;
}
if(verifycode==''){
layer.alert('请输入验证码',{icon:2});
return;
}
$.post('/admin.php/admin/Account/dologin',{'username':username,'pwd':pwd,'verifycode':verifycode},function(res){
if(res.code>0){
layer.alert(res.msg,{icon:2});
}else{
layer.msg(res.msg);
setTimeout(function(){window.location.href='/admin.php/admin/Home/index'},1000);
}
},'json');
}
</script>
</body>
</html>