ich hoffe cih bin hier richtig , ich habe jetzt einige zeit mit ajax verbracht mein probelm ich möchte das die date die per ajax aufrufe sich ständig aktuell hält.
hier mal die ajax.php
PHP-Code:
<script type="text/javascript">
//<![CDATA[
var ajax=false;
if (window.XMLHttpRequest)
{
ajax=new XMLHttpRequest;
}
else if (window.ActiveXObject)
{
ajax=new ActiveXObject('Microsoft.XMLHTTP');
}
function load()
{
ajax.open('GET', 'time.php');
ajax.onreadystatechange=function()
{
if (ajax.readyState==4)
{
window.document.getElementById('time').innerHTML=
ajax.responseText;
}
}
ajax.send(null);
}
if (ajax)
{
window.document.writeln('<p>');
window.document.writeln('Serverzeit');
window.document.writeln('[<a href="#" id="refresh">aktualisieren</a>]:');
window.document.writeln('<span id="time">...</span>');
window.document.writeln('</p>');
window.document.getElementById('refresh').onclick=load;
window.onload=load;
}
//]]>
</script>
und hier die time.php die per ajax immer akutell gehalten werden soll.
PHP-Code:
<?php
// -----------------------
// --- Datei: time.php ---
// -----------------------
// Seite soll nicht aus dem Cache geladen werden.
header('Cache-Control: no-cache');
// Unix-Zeitstempel ausgeben.
$time = time();
echo '
<head><meta http-equiv="refresh" content="0; url=#"></head>
<table width="795" height="30" cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td class="HeaderColor">InGame Übersicht: Ressourcen @ 1:17:233 (Nova)</td>
</tr>
<tr>
<td></td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="700" height="71">
<tr>
<td align="center" height="23" width="13%">Trinium</td>
<td align="center" height="23" width="13%">Fuel</td>
<td align="center" height="23" width="13%">Darkmatter</td>
<td align="center" height="23" width="13%">Gold</td>
<td align="center" height="23" width="13%">Energie</td>
<td align="center" height="23" width="13%"><a href="./index.php?ACTION=Messages">Nachrichten</a></td>
</tr>
<tr>
<td align="center" height="29" width="13%"><img src="http://themepack.galaxyfighters.net/css_images/metall.gif" width="33" height="17"></td>
<td align="center" height="29" width="13%"><img src="http://themepack.galaxyfighters.net/css_images/silicium.gif" width="33" height="17"></td>
<td align="center" height="29" width="13%"><img src="http://themepack.galaxyfighters.net/css_images/tritium.gif" width="33" height="17"></td>
<td align="center" height="29" width="12%"><img src="http://themepack.galaxyfighters.net/css_images/gold.gif" width="33" height="17""></td>
<td align="center" height="29" nowrap width="14%">
<img border="0" src="http://themepack.galaxyfighters.net/css_images/energie.jpg" width="33" height="17">
</td>
<td align="center" height="29" width="12%">
<a href="main.php?site=msg&login_id=14&msg_center=1">
<img src="http://themepack.galaxyfighters.net/css_images/messagebig.gif" border="0" width="32" height="32">
</a>
</td>
<td align="center" height="19" valign="top">
<b>Serverzeit</b>
'.date( "H:i:s",time()).'
</td>
<td align="center" height="19" valign="top">
<b> <img src="http://themepack.galaxyfighters.net/css_images/uhr.gif" border="0" width="8" height="8"> </b>
</td>
<td align="center" height="19" valign="top">
<b>Punkte</b>
<script type=text/javascript>
document.write(FormatNumber(55229));
</script>
</td>
<td align="center" height="29" width="12%">
</td>
</tr>
<tr>
<td align="center" height="19" width="13%">
<font color="#FFFFFF">
<script type="text/javascript">
document.write(FormatNumber(217507));
</script>
</font>
</td>
<td align="center" height="19" width="12%">
<font color="#FFFFFF">
<script type="text/javascript">
document.write(FormatNumber(149613));
</script> </font>
</td>
<td align="center" height="19" width="13%">
<font color="FFFFFF">
<script type="text/javascript">
document.write(FormatNumber(11183));
</script>
</font>
</td>
<td align="center" height="19" width="12%">
<font color="FFFFFF">
<script type="text/javascript">
document.write(FormatNumber(2369));
</script>
</font>
</td>
<td align="center" height="19" nowrap width="13%"><font color="#00CC00"></font><b><font color=green>60</font></b></td>
<td align="center" height="19" nowrap width="13%">0 / 0</td>
</tr>
</table>
<marquee scrollamount=1 scrolldelay=1>++ G-F : NG Hotnews : Viel spaß</marquee>
</td>
</tr>
<tr>
<td height="10"></td>
<td></td>
</tr>
<tr>
<td></td>
<td> ';
?>
was muss ich verändern das ich net immer im ajax script auf "aktualisieren" klicken mus sondern das er das automatisch macht?
MFG
neon