JS 统计用户访问情况

 1 var guid = '';
 2 var pageUrl = window.location.href;
 3 $(function () {
 4     $.ajax({
 5         type: "GET",
 6         url: 'http://xxxx.cn/weeshow/Admin/B2C/NBPlanVisitor/FirstVisit?pageUrl=' + pageUrl,
 7         dataType: 'jsonp',
 8         jsonp: "callback",
 9         jsonpCallback: "jsonpCallback",
10         processData: false,
11         async: false,
12         success: function (data) {
13             guid = data[0].Guid;
14             CheckVisit();
15         },
16         error: function (XMLHttpRequest, textStatus, errorThrown) {
17             //alert(XMLHttpRequest.status);
18             //alert(XMLHttpRequest.readyState);
19             //alert(textStatus);
20             console.log("提交失败!");
21         }
22     });
23 
24 })
25 function CheckVisit() {
26     setTimeout(function () {
27         $.ajax({
28             type: "GET",
29             url: 'http://xxx.cn/weeshow/Admin/B2C/NBPlanVisitor/CheckVisit?guid=' + guid,
30             dataType: 'jsonp',
31             jsonp: "callback",
32             jsonpCallback: "jsonpCallback",
33             processData: false,
34             async: false,
35             success: function (data) {
36                 CheckVisit();
37             },
38             error: function (XMLHttpRequest, textStatus, errorThrown) {
39                 console.log("提交失败!");
40             }
41         });
42     }, 1000);
43 }

 

posted @ 2019-01-29 10:48  巴蒂尔  阅读(289)  评论(0编辑  收藏  举报