标签:conf 签到 button tostring span $.ajax click 当前时间 str
<script> $(function () { $("#qiandao").click(function () { var b = new Date(); var str = ""; str += b.getHours() + ":"; str += b.getMinutes() + ":"; str += b.getSeconds(); $.ajax({ url: ‘/cxl/qiandao‘, data: { time: str }, type: ‘post‘, success: function (data) { if (data == 0) { alert(‘签到失败!!‘); } else { alert("签到成功!"); $("#s1").html(str); } } }) }) }) function shijian() { var d = new Date(), str = ‘‘; str += d.getFullYear() + ‘年‘; str += d.getMonth()+ 1 + ‘月‘; str += d.getDate() + ‘日‘; str += d.getHours() + ‘:‘; str += d.getMinutes() + ‘:‘; str += d.getSeconds()+‘ ‘; str += ‘今天星期‘ + d.getDay(); return str; } setInterval(function () { $(‘#dangqinashijian‘).html(shijian()) }, 1000); </script> <h2>当前时间:<span id="dangqinashijian"></span></h2> <input id="qiandao" type="button" value="签到" /><span id="s1"></span><br /> <input id="qiantui" type="button" value="签退" /> qiandao方法: public int qiandao(string time) { //获取规定上班的时间 string times = ConfigurationManager.AppSettings["up"].ToString(); if (DateTime.Parse(time) > DateTime.Parse(times)) { //如果超过规定时间就算是迟到,打不上卡 return 0; } else { return 1; } } MVC webcfg: <appSettings>标签内 <add key="up" value="08:00:00"/>
标签:conf 签到 button tostring span $.ajax click 当前时间 str
原文地址:https://www.cnblogs.com/caoxiaole/p/10003172.html