View Full Version : xmlHttpRequest Chat Program help
Basscyst
08-05-2005, 11:28 PM
I'm just learning this here so bare with me, I have the following page:
http://www.loanupload.com/pipeline/test/chat/chat.html That seems to work beautifully for me. Unfortunatley when someone else goes to use it, it just clears out the messages when they send it. The data gets updated in the xml page, but isn't reflected to the user except for a split second then it goes away. If you would like to view the xml doc you can see it at:
http://www.loanupload.com/pipeline/test/chat/checkmessages.asp
Any guidence is greatly appreciated.
Thanks,
Basscyst
hemebond
08-06-2005, 12:07 AM
Your XML file is invalid, and I'm getting Javascript errors.
Basscyst
08-06-2005, 12:08 AM
Yeah, I am now too. I can work through the javascript errors, but what is wrong with the xml file?
Basscyst
hemebond
08-06-2005, 12:12 AM
I think maybe it's because you have white-space before the XML prologue.
dumpfi
08-06-2005, 12:15 AM
If I visit your ASP page it displays an error because the XML processing instruction is not at the beginning of the external entity (bad translation of the firefox error message).
I have, however, no clue what this means.
dumpfi
Basscyst
08-06-2005, 12:31 AM
Yea, I fixed the whitespace at the top and that seems to have fixed the xml error. I think my error lies in the JS.
Thanks,
Basscyst
Basscyst
08-06-2005, 12:59 AM
Does this thing seem to work right for anyone else? I now have no errors, and it updates and sends just fine for me, but non of my co-workers are succesfull. :confused:
Perhaps it is in how I am checking for new messages? I have a setInterval checking for new messages in the database every second, the asp page calls the db and creates an xml page from the results, which is then returned to the document. . .is there a better way?
Basscyst
hemebond
08-06-2005, 01:14 AM
I'm getting continuous "req not defined" errors. Are you using delta updates or just getting the whole document again? Do the messages have unique ID's or timestamps? What perameters does checkmessages.asp accept? Will it return a 304 when there are no new messages?
Basscyst
08-06-2005, 01:15 AM
Nope, what's a delta update? I am generating the whole xml doc with each check. Here is a copy of the pertinent code in the ASP pages.
Checking Messages
<?xml version="1.0" encoding="ISO-8859-1" ?>
<messages>
<%
For i=0 To rs.RecordCount-1
%>
<message>
<from><%=rs.Fields(1)%></from>
<content><%=rs.Fields(2)%></content>
</message>
<%
rs.MoveNext
Next
rs.Close
%>
</messages>
New Messages
dim from,msg
from=Request.QueryString("user")
msg=Request.QueryString("msg")
set rs=getSQL("INSERT INTO Chat (u_name,msg) VALUES('" & replace(from,"'","''") & "','" & replace(msg,"'","''") & "')")
set rs=getSQL("SELECT * FROM chat")
%><?xml version="1.0" encoding="ISO-8859-1" ?><messages><%For i=0 To rs.RecordCount-1%><message><from><%=rs.Fields(1)%></from><content><%=rs.Fields(2)%></content></message>
<%rs.MoveNext
Next
rs.Close%></messages>
Basscyst
hemebond
08-06-2005, 01:19 AM
Delta updates (or compression) returns only the data that has changed since the last state. You should be sending a timestamp of the last update the client received, to the system, which returns only those messages that arrived after that time. This is then appended to the current dataset by the client.
Basscyst
08-06-2005, 01:23 AM
Ok, that makes sense. I'll do some rework this weekend. This has really just been a learning excersise, and I have a pretty good understanding. Would like for it to work right though, so I'll have to see it through. I'm going to take down the link now so as not to bombard my works server. :p
Thanks for the help.
Basscyst
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.