1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>web_GET</title>
6 </head>
7 <body>
8 <button class="btn">发送GET请求</button>
9 <script src="./jquery.min.js"></script>
10 <script>
11 var page = {
12 init : function(){
13 this.bindEvent();
14 },
15 bindEvent : function(){
16 var _this = this;
17 $(document).on('click','.btn',function(){
18 //产生一个5位的随机数
19 var rnd = _this.randomNum(5);
20 console.log(rnd);
21 $.ajax({
22 type : 'get',
23 url : 'http://10.10.0.190:3000/WorkStat/workstat/get_user_latest_work_hist?rnd='+rnd,
24 dataType : 'json',
25 data : {
26 user_id : 02519
27 },
28 success : function(res){
29 console.log(res);
30 },
31 error : function(err){
32 console.log(err);
33 }
34
35 })
36 })
37 },
38 //产生随机数函数
39 randomNum : function(n){
40 var randomNum = '';
41 for(var i=0; i<n; i++){
42 randomNum += Math.floor(Math.random()*10);
43 }
44 return randomNum;
45 }
46 }
47 $(function(){
48 page.init();
49 })
50 </script>
51 </body>
52 </html>