30 lines
838 B
PHP
30 lines
838 B
PHP
<h1>Live resultater</h1>
|
|
<p id="response">Venter på data...</p>
|
|
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
|
|
<script>
|
|
function getContent(timestamp)
|
|
{
|
|
var queryString = {'timestamp' : timestamp};
|
|
|
|
$.ajax(
|
|
{
|
|
type: 'GET',
|
|
url: 'long-polling.php',
|
|
data: queryString,
|
|
success: function(data){
|
|
// put result data into "obj"
|
|
var obj = jQuery.parseJSON(data);
|
|
// put the data_from_file into #response
|
|
$('#response').html(obj.data);
|
|
// call the function again, this time with the timestamp we just got from server.php
|
|
getContent(obj.timestamp);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
// initialize jQuery
|
|
$(function() {
|
|
getContent();
|
|
});
|
|
</script> |