(前几天 一直弄二维码轮询登录 想了半天 总算弄出来了 分享给大家      ^-^)

轮询:

   所谓轮询 肯定需要 setInterval   但是怎么加ajax请求  需要有点小问题而且轮询成功后需要停止  下来看代码吧

var tis = setInterval(function(){$.ajax(getting)},3000);//{调用ajax(自己封装的数据)},每3秒执行一次
var getting = {
type:'GET',
url://地址,
success: function (obj) {
console.log(obj)
  //这里需要你判断服务器返回的数据
//成功后取消clearTimeout(tis);
},
error: function (err) {
console.log(err);
}
}

大家如果写扫码登录的话 肯定在URL地址拼接时间戳  给大家写一个时间戳的封装函数 直接调用即可

Date.prototype.format = function (format) {
var args = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds()
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var i in args) {
var n = args[i];
if (new RegExp("(" + i + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
}
return format;
};
var tims = new Date().format("yyyyMMddhhmmssS")//调用格式根据需求比如:("yyyy-MM-dd-hh-mm-ssS")
console.log(tims)

^-^

最新文章

  1. How to Use Lucene.NET with Windows Azure SQL Database
  2. 【leetcode】Spiral Matrix(middle)
  3. SQL查询语句去除重复行
  4. 全栈式JavaScript
  5. Linux内核--usb子系统的分析
  6. location.hash && location.href
  7. [洛谷1580]yyy loves Easter_Egg I
  8. shell中case的用法学习笔记
  9. Building Local Unit Tests
  10. 2014第8周一JS正则小问题
  11. Struts2学习笔记③
  12. xlwt 官网的例子
  13. thinkphp实现like模糊查询实例
  14. 网络爬虫&起点中文网完本榜500部小说
  15. linux下 /usr/bin/ld: 找不到 -ldhnetsdk的解决方法
  16. Android 数据库框架总结(转)
  17. 复制文件描述符---dup
  18. Android 查看自己的keystore的别名及相关信息
  19. golang模拟新浪微博登录
  20. SRS Audio Sandbox没有声音怎么办

热门文章

  1. python pandas进行条件筛选时出现ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().”
  2. [翻译] ASP.NET Core 3.0 的新增功能
  3. 离线环境下进行pip包安装
  4. JAVA设计模式-动态代理(Proxy)源码分析
  5. Mysql - 关于relay_log_recovery参数的测试
  6. SpringBootSecurity学习(06)网页版登录方法级别的权限
  7. 基于Docker搭建大数据集群(一)Docker环境部署
  8. Spring 梳理-el表达式和jstl
  9. 节点操作--JavaScript
  10. windows下查看进程及结束进程命令