Neden sever zaman alamıyor?

0 Cevap php
<html>
<head>
<title>Ajax Demonstration</title>
<style>
.displaybox {
width:150px;
background-color:#ffffff;
border:2px solid #000000;
padding:10px;
font:24px normal verdana, helvetica, arial, sans-serif;
}
</style>
<script language="JavaScript" type="text/javascript">
//<%=new java.util.Date()%>

function getXMLHTTPRequest() {
    alert("Hello! I am an alert box!");
    try {
        req = new XMLHttpRequest();
    } catch (err1) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (err2) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (err3) {
                req = false;
            }
        }
    }
    return req;
}
var http = getXMLHTTPRequest();

function getServerTime() {
    var myurl = 'http://localhost/csp 2/telltimeXML.php';
    myRand = parseInt(Math.random() * 999999999999999);
    // var modurl = myurl+"?rand="+myRand;
    http.open("GET", myurl, true);
    http.onreadystatechange = useHttpResponse;
    http.send(null);
}

function useHttpResponse() {
    if (http.readyState == 4) {
        if (http.status == 200) {
            var timeValue = http.responseXML.getElementsByTagName("timenow")[0];
            alert(timeValue);
            document.getElementById('showtime').innerHTML = timeValue.childNodes[0].nodeValue;
        }
    }
}
</script>
</head>
<body style="background-color:#cccccc"
 onLoad="getServerTime()">
<center>
<h1>Ajax Demonstration</h1>
<h2>Getting the server time without page refresh</h2>
<form>
<input type="button" value="Get Server Time"
 onClick="getServerTime()">
</form>
<div id="showtime" class="displaybox"></div>
</center>
</body>
</html>

PHP dosyası için kod:

<?php header('Content-Type: text/xml'); echo "<?xml version=\"1.0\" ?><clock1><timenow>" .date('H:i:s')."</timenow></clock1>"; ?>

0 Cevap