Google weiß alles: FUNZT

Beitrag lesen

Und nun probier das mal im Internet Explorer.

Bin ich Jesus? Kann ich Lahme zum Laufen bringen?

Den hier schon:

<!DOCTYPE html>
<html>
<body>
<!-- FILE: /var/www/Tests/Server-Sent-Json.html -->
<h1>Getting server updates</h1>
<div id="result"></div>

<script>
function ServerEvents() {
    var data;
    var xmlHttp = new XMLHttpRequest();
    if (xmlHttp) {
        xmlHttp.open('GET', 'Server-Sent-Json.php', true);
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4) {
                data=JSON.parse(xmlHttp.responseText);
                window.setTimeout("ServerEvents()", data['retry']);
                document.getElementById("result").innerHTML=data['data']
            }
        };
        xmlHttp.send(null);
    }
}
ServerEvents();
</script>
</body>
</html>
<?php
## FILE: /var/www/Tests/Server-Sent-Json.php
header('Content-Type: text/json');
header('Cache-Control: no-cache');
$out['data'] = 'The server time is: ' . date('r');
$out['retry'] = 1000;
echo json_encode($out);
flush();
?>