jquery 获取服务器时间

来源:互联网 发布:60知天命 编辑:程序博客网 时间:2024/06/05 14:55
/**2012-10-12 buy.js通过ajax方式返回服务器时间*/$(document).ready(function (){var url="/ajax/comm.shtml?action=getTime";jQuery.ajax(url,{data: "",dataType: "json",cache: false,success: function(req){callbackTime(req);    },    error: function(msg){    alert("ERROR:请刷新页面!");}});$("#but1").click(function(){jqueryTest();});});var srv_nowtime;function callbackTime(req){var timeArr = req.split("&");srv_nowtime = new Date(timeArr[0]).getTime();showTime();window.setInterval(showTime, 1000); }function showTime(){srv_nowtime += 1000;var nowtime = new Date(srv_nowtime);var ymd = nowtime.getFullYear() + ""+ (nowtime.getMonth()+1) +""+ (nowtime.getDate()<10?"0"+nowtime.getDate():nowtime.getDate());//alert(ymd);}
0 0
原创粉丝点击