12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title></title>
- </head>
- <body>
- <?php
- if(@$_GET["action"]=="getTime"){
- $time1 = Time()+13000;
- $date1 = date("H:i:s T",$time1);
- echo '<font size="5" color="#000000">'.$date1.'</font><br>';
- die();
- }
- ?>
- <div id="qwe">test</div>
- <script type="text/javascript">
- window.onload = startInterval;
- function startInterval() {
- setInterval("startTime();",1000);
- }
- function startTime() {
- AX = new ajaxObject("?action=getTime", showTime)
- AX.update(); // start Ajax Request
- }
- // CallBack
- function showTime( data ){
- document.getElementById('qwe').innerHTML = data;
- }
- </script>
- <script type="text/javascript">
- // Ajax Object - Constructor
- function ajaxObject(url, callbackFunction) {
- var that=this;
- this.updating = false;
- this.abort = function() {
- if (that.updating) {
- that.updating=false;
- that.AJAX.abort();
- that.AJAX=null;
- }
- };
- this.update =
- function(passData,postMethod) {
- if (that.updating) { return false; }
- that.AJAX = null;
- if (window.XMLHttpRequest) {
- that.AJAX=new XMLHttpRequest();
- }else{
- that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
- }
- if (that.AJAX==null) {
- return false;
- }else{
- that.AJAX.onreadystatechange = function() {
- if (that.AJAX.readyState==4) {
- that.updating=false;
- that.callback( that.AJAX.responseText, that.AJAX.status, that.AJAX.responseXML, that.AJAX.getAllResponseHeaders() );
- that.AJAX=null;
- }
- };
- that.updating = new Date();
- if (/post/i.test(postMethod)) {
- var uri=urlCall+(/\?/i.test(urlCall)?'&':'?')+'timestamp='+that.updating.getTime();
- that.AJAX.open("POST", uri, true);
- that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- that.AJAX.setRequestHeader("Content-Length", passData.length);
- that.AJAX.send(passData);
- }else{
- var uri=urlCall+(/\?/i.test(urlCall)?'&':'?')+passData+'×tamp='+(that.updating.getTime());
- that.AJAX.open("GET", uri, true);
- that.AJAX.send(null);
- }
- return true;
- }
- };
- var urlCall = url;
- this.callback = callbackFunction || function (){};
- }
- </script>
- </body>
- </html>
|