/** 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); }
jquery 获取服务器时间
最新推荐文章于 2021-08-05 11:51:42 发布