הקוד js :
קוד:
function ajax_read() {
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
if(xmlhttp.overrideMimeType){
xmlhttp.overrideMimeType('text/xml');
}
} else if(window.ActiveXObject){
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e){
}
}
}
if(!xmlhttp) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
//document.getElementById("content").innerHTML ='reload..</h1>'
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
document.getElementById("content").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET','test.php');
xmlhttp.send(null);
}
function refresh()
{
ajax_read()
var t;
t=setTimeout("refresh()",1000);
}
זה הדף refresh.js
ועכשיו זה הקוד של הדף test.php :
קוד:
<?
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-Type: text/html; charset=windows-1255');
include "config.php";
$result = mysql_query("SELECT * FROM result");
//$row = mysql_fetch_assoc($result);
?>
<html dir=rtl>
<head>
<title>בלה בלה</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1255" />
<script type="text/javascript" src="instantedit.js"></script>
<script type="text/javascript" src="refresh.js"></script>
</head>
<body onload="refresh()">
<div id="content">
<table>
<? while ($row = mysql_fetch_assoc($result)) { ?>
<tr>
<td><span id="home-|||-<?php echo $row['id']; ?>" class="editText"><? echo $row['home']; ?></span></td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
עכשיו תראו ככה זה לא עובד...
ושאני עושה
קוד:
<div id="content"></div>
שבפנים אין כלום זה כן עובד.. מה הקטע?