![]() |
# 1 |
חסום
|
עזרה ב ajax רענונים אוטומטים
הקוד 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); } ועכשיו זה הקוד של הדף 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> Last edited by kfir91; 26-08-08 at 16:53.. |
![]() |
חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים) | |
|
|