(The last few days have been made QR code polling login thought for a long time finally came out to share to everyone ^-^)
Polling:
The so-called polling definitely needs setinterval But how to add AJAX requests needs a little bit of a problem and you need to stop looking at the code after a successful poll
var tis = setinterval (function () {$. Ajax (getting)},3000); // {calls Ajax (own encapsulated data), executes once every 3 seconds var getting = {type: ' GET '
If you write a scan code to log in, it must be in the URL address stitching time stamp to everyone to write a timestamp of the package function directly call can
Date.prototype.format =function(format) {varargs = { "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(varIinchargs) { varn =Args[i]; if(NewRegExp ("(" + i + ")"). Test (format)) format= Format.replace (regexp.$1, regexp.$1.length = = 1? N: ("xx" + N). substr ("" +( N). length)); } returnformat;};varTims =NewDate (). Format ("Yyyymmddhhmmsss")//Call format according to requirements such as: ("Yyyy-mm-dd-hh-mm-sss")Console.log (Tims)
^-^
Ajax polling (for web-side QR code requests)