ערכתי לאחרונה בתאריך 09.07.07 בשעה 17:30 בברכה, djME
אז ככה יש לי קוד שמראה כמה אנשים גולשים באתר שלי ברגע זה..
הקוד דינאמי בעזרת Ajax אני מוכרח לציין כי לא אני כתבתי אותו אלה משכחתי אותו מאתר מסויים.. ואני לא ממש מבין ב Ajaxהבעיה כזאת ב FireFox הכל עובד פרפקט אבל ב Internet Explorer הוא פשוט לא מתעדכן כל כמה שניות אלה נתקע עם התוצאה הראשונה שלו ממש וכאילו והוא לא דינמי
אשמח לאיתור הבעיה ותיקונה.. תודה רבה רבה
this is the check.php
<?php // idle time in minutes define("MAX_IDLE_TIME", 3);
/** * online class : * * @package * @author Ben Yacoub Hatem <[email protected]> * @copyright Copyright (c) 2004 * @version $Id: online.class.php,v 1.1 2005/03/16 06:20:57 hatem Exp $ - 25/05/2004 14:04:22 - online.class.php * @access public **/ class online{ /** * Constructor * @access protected */ function online(){ } /** * * @access public * @return void **/ function who(){ $path = session_save_path(); if (trim($path)=="") { return FALSE; } $d = dir( $path); $i = 0; while (false !== ($entry = $d->read())) { if ($entry!="." and $entry!="..") { if (time()- filemtime($path."/$entry") < MAX_IDLE_TIME * 60) { $i++; } } } $d->close(); return $i; } } echo online::who(); ?>
|
This is the Index.php
<html><head> <title>AJAX Online Users</title> </head> <script language="javascript" type="text/javascript"> var RequestObject = false; // XMLHttpRequest Object var Backend = 'http://MY-DOMAIN.com/check.php'; // Backend url window.setInterval("update_timer()", 4000); // update the data every 20 mins if (window.XMLHttpRequest) // try to create XMLHttpRequest RequestObject = new XMLHttpRequest();
if (window.ActiveXObject) // if ActiveXObject use the Microsoft.XMLHTTP RequestObject = new ActiveXObject("Microsoft.XMLHTTP"); /* * onreadystatechange function */ function ReqChange() {
// If data received correctly if (RequestObject.readyState==4) { // if data is valid if (RequestObject.responseText.indexOf('invalid') == -1) { // getting the response var msgs = RequestObject.responseText.split('|'); // Tell the reader the everything is done document.getElementById("online").innerHTML = msgs+" Online Users"; } else { // Tell the reader that there was error requesting data document.getElementById("online").innerHTML = "Error Requesting data"; } } } /* * Main AJAX RSS reader request */ function AJAXRequest() {
// change the message to Checking online ... //document.getElementById("online").innerHTML = "Checking online ..."; // Prepare the request RequestObject.open("GET", Backend , true); // Set the onreadystatechange function RequestObject.onreadystatechange = ReqChange; // Send RequestObject.send(null); } /* * Timer */ function update_timer() { AJAXRequest(); } </script>
<body onload="AJAXRequest();"> <div id="online"></div> </body> </html>
|