jqueryサーバ取得時間
1075 ワード
/**
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);
}