回答編集履歴
1
追記
test
CHANGED
@@ -33,3 +33,43 @@
|
|
33
33
|
```
|
34
34
|
|
35
35
|
ただし1秒おきにサーバーに外部アクセスするのはちょっと危険かも・・・
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# 非jQuery
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```javascript
|
44
|
+
|
45
|
+
function jsont(json){
|
46
|
+
|
47
|
+
var tm = new Date( json["st"] * 1000 );
|
48
|
+
|
49
|
+
console.log( tm.toLocaleString() );
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
var url="http://ntp-a1.nict.go.jp/cgi-bin/jsont";
|
54
|
+
|
55
|
+
var xhr=new window.XMLHttpRequest();
|
56
|
+
|
57
|
+
setInterval(function(){
|
58
|
+
|
59
|
+
xhr.open('get',url);
|
60
|
+
|
61
|
+
xhr.send(null);
|
62
|
+
|
63
|
+
xhr.onreadystatechange=function(){
|
64
|
+
|
65
|
+
if(( xhr.readyState == 4 ) && ( xhr.status == 200 )){
|
66
|
+
|
67
|
+
eval(xhr.responseText);
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
},1000);
|
74
|
+
|
75
|
+
```
|