This repository has been archived on 2023-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
web/app/view/pages/race/live-results.php
2022-03-21 12:28:18 +01:00

30 lines
838 B
PHP

<h1>Live resultater</h1>
<p id="response">Venter 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>