This is split between AJAX and ASP but should go here... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

This is split between AJAX and ASP but should go here...

[b][red]This message was edited by aaronjones3593 at 2007-3-9 2:1:24[/red][/b][hr]
I'm making a web chat application and I'm a bit stumped on something. It uses a database to keep track of who's online, and I have an AJAX form thing that gets the contact list from list.asp every 5 seconds; like so...



Loading the contact list...

var AJAXObject = null;
try { AJAXObject = new XMLHttpRequest(); } catch (e) { /* Not using Firefox, Safari or Opera */ }
try { AJAXObject = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { /* Not using Internet Explorer */ }

var Timer = 2000;

function GetContactList()
document.getElementById("SendFormSeperator").style.display = "none";
document.getElementById("SendTextForm").style.display = "none";
if (AJAXObject != null)
var LoginHandle = "<%=Session("LoginHandle")%>"
AJAXObject.onreadystatechange = stateChanged();"GET", "./list.asp?sid=" + Math.random() + "&LoginHandle=" + LoginHandle, true);

window.setTimeout("GetContactList()", Timer);
Timer = 5000
alert("Your browser does NOT support AJAX!")

function stateChanged()
if (AJAXObject.readyState == 4)
var ResponseText = AJAXObject.responseText;
document.getElementById("ContactList").innerHTML = ResponseText;
if (ResponseText.indexOf("No online users") == -1)
document.getElementById("SendFormSeperator").style.display = "";
document.getElementById("SendTextForm").style.display = "";


Dim adoCon
Dim Recordset
Dim strSQL

Set adoCon = Server.CreateObject("ADODB.Connection")
Set Recordset = Server.CreateObject("ADODB.Recordset")

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("./db/users.mdb")

strSQL = "SELECT UserID,CurrentStatus,DisplayName FROM WCAUsers WHERE CurrentStatus <> 'offline'"
strSQL = strSQL & " AND LoginHandle <> '" & Request.QueryString("LoginHandle") & "'"
Recordset.Open strSQL, adoCon

IF Recordset.EOF Then
Response.Write ""
End If

Do While Not Recordset.EOF
Response.Write ""

Set Recordset = Nothing
Set adoCon = Nothing
No online users
" & _
"image " & _
Recordset("DisplayName") & "

as you can see in list.asp it gets the users where their status is not offline... but some people just close the window without signing out first. I don't want something that will tell them to sign out first when they click the X button ot anything; I want something that I can do in AJAX/ASP to check on the client say like every 30 seconds or so... and if there is no response (closed the window, anyone?) then force sign them out (update database status to offline).

I'm a bit stuck on thinking how I could do/implement this... any ideas?

Thanks in advance,

Sign In or Register to comment.