<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>web_GET</title>
</head>
<body>
<button class="btn">发送GET请求</button>
<script src="./jquery.min.js"></script>
<script>
var page = {
init : function(){
this.bindEvent();
},
bindEvent : function(){
var _this = this;
$(document).on('click','.btn',function(){
//产生一个5位的随机数
var rnd = _this.randomNum(5);
console.log(rnd);
$.ajax({
type : 'get',
url : 'http://10.10.0.190:3000/WorkStat/workstat/get_user_latest_work_hist?rnd='+rnd,
dataType : 'json',
data : {
user_id : 02519
},
success : function(res){
console.log(res);
},
error : function(err){
console.log(err);
} })
})
},
//产生随机数函数
randomNum : function(n){
var randomNum = '';
for(var i=0; i<n; i++){
randomNum += Math.floor(Math.random()*10);
}
return randomNum;
}
}
$(function(){
page.init();
})
</script>
</body>
</html>