sunjianghua2018
2018-06-20 05:42
采纳率: 60%
浏览 4.3k
已采纳

click事件的ajax触发不了,请求大神解答

 <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>登录</title>
<link rel="icon" href="/assets/images/favicon.ico?verson=<%=Math.random()%>>">
<link href="/assets/css/base1.css" rel="stylesheet" type="text/css" />  
<link href="/assets/css/base.css" rel="stylesheet" type="text/css" />
<link href="/assets/css/global.css" rel="stylesheet" type="text/css" />
<style type="text/css">
    .login_fs {
        position: absolute;
        right: 0;
        top: 9.5%;
        width: 52px;
        height: 52px;
        cursor: pointer;
        z-index:100
    }
    .qrcode_btn {
        background: #ffffff url(/assets/images/loginfs.png) no-repeat;
    }
    .qrcode_btn:hover {
        background: #ffffff url(/assets/images/loginfs.png) no-repeat 0px -60px;
    }
</style>
<script type="text/javascript" src="/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="/assets/js/jquery-ui.min.js"></script>
<script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
</head>
<body class="login_bg">
<div class="logo"><div class="fl"><img src="/assets/images/logo.png?verson=<%=Math.random()%>>"/></div><div class="fl logolm">办公系统</div></div>
<div class="login">
<div class="login_fs qrcode_btn" title="微信扫码登录" onclick="showQrcode()"></div>
<div id="login">
<form action="/login" method="post" id="myform" class="form-horizontal" >
<div class="login_tab">
<div class="lm">员工登录</div>
<div class="login_form">
<ul>
<li class="login_user"><input id="userName" name="staffVO.userName" type="text" style="width:95%" class="login_text" value="" placeholder="登录用户名" required autofocus /></li>
<li class="login_pass"><input id="password" name="staffVO.password" type="password" style="width:95%" class="login_text" placeholder="登录密码" required/><span class="error">${errorMessage }</span></li>
<li class="login_btndiv" style="margin-top: 25px"><input id="Button1"  type="submit" value="登录" class="login_btn"/></li>
</ul>
</div>
<div class="mt10"><a href="/toResetStep1" style="color:#ee5252" >忘记密码/花名</a></div>

<div class="mt10">地区:通州,南通,如东,广州,南京,佛山</div>
</div>
</form>
<div class="login_banner">创新&nbsp;&nbsp;专业&nbsp;&nbsp;合作&nbsp;&nbsp;务实</div>
</div>
</div>
<div id="loginTab" style="position:absolute;top:20%;left:38%;display:none"></div>
<script type="text/javascript">
$(function(){
     var code = '${param.code}';
     if(code){
         location.href = "/index"+location.search;
     }
});
var appID = "wx9c2800cfc46895f0";
var uri = "http://www.zhizaolian.com:9090";
var obj = new WxLogin({
  id: "loginTab",
  appid: appID,
  scope: "snsapi_login", 
  redirect_uri: encodeURI(uri),
  state: guid()
});
function showQrcode(){
    $(".login").css("opacity", "0.1");
    $(".logo").css("opacity", "0.1");
    $("#loginTab").css("display", "block");
    $("input").css("pointer-events", "none");
    $(".qrcode_btn").css("pointer-events", "none");
}
$("#login, .logo").click(function(){
    if($("#loginTab").css("display")=='block'){
        $("#loginTab").css("display", "none");
        $(".login").css("opacity", "1");
        $(".logo").css("opacity", "1");
        $("input").css("pointer-events", "");
        $(".qrcode_btn").css("pointer-events", "");
    }
});
function guid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
        return v.toString(16);
    });
}
$("#Button1").click(function(){
    alert(1);
    var userName =$("#userName").val();
    var password =$("#password").val();
    $.ajax({
        url:'/chaxunContract',
        type:'post',
        data:{userName:userName,password:password},
        dataType:'json',
        success:function(data){
            alert(2);
            alert(data.diff);

            if(data.diff>3){
                var params = $("#myform").serialize();
                window.location.href="/login"+ decodeURICompoent(params,true);
                Load.Base.LoadingPic.FullScreenShow(null);
            }else if(data.diff<=3 && data.diff>=0){
                layer.open({
                    offset:'100px',
                    title:'提醒',
                    content:"您的劳动合同于"+data.endDate+"到期,请联系人事部门进行续签",
                    success:function(index){
                        layer.close(index);
                        var params = $("#myform").serialize();
                        window.location.href="/login"+ decodeURICompoent(params,true);
                        Load.Base.LoadingPic.FullScreenShow(null);
                    }
                })
            }else if(data.diff<0){
                layer.alert("您的劳动合同已于"+data.endDate+"到期,请联系人事部门进行续签后再登录");
            }else if(data.diff=='no'){
                layer.alert("您暂时未签署劳动合同,请联系人事部门进行签署后再登录");
            }
        }
    })
})
</script>
</body>
</html>

click事件的ajax触发不了,请求大神解答

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

17条回答 默认 最新

  • wodexinhao 2018-06-20 05:51
    最佳回答

    还有就是你这ajax里面要加入错误检查机制,如果你发送的数据格式不正确或者其它错误,服务器会返回相关的错误信息,根据错误信息找到错误原因,你这里只有success: 成功后执行代码,没有错误处理机制

    评论
    解决 无用
    打赏 举报
查看更多回答(16条)

相关推荐 更多相似问题