kratsg Posted October 17, 2007 Share Posted October 17, 2007 The files with source code will be posted as soon as I can get access back on the FTP I've got an AJAX Chatroom set up and working. Problems are speed mainly. For example, I have two ajax requests that are being sent, both every 3 seconds. One request gets all the messages (up to a certain point) from the database, returns html and the javascript simply puts that into the div. The second one gets the current users in the chatroom (based on the server, sorts by most recent to not most recent), returns html and the javascript puts in another div. The new messages has the following variables per message: Timestamp (HH:MM am/pm) Optional Image in front of username Username message id/message number Each message has this format: IMG? Username: (timestamp) Message (post number) The messages will be very simple, the tag that wraps the whole message will most likely be a span tag and contains the text-color and bgcolor attributes. The users list has the following: Timestamp (HH:MM am/pm) Optional Image in front of username Username IMG? (link for options to contact user) Username (timestamp) The link for options to contact user is to send a personal message, clicking it will change the div at the bottom to display links for different things. This is not going to be included in the output from the php file. One problem is the speed, that the server is taking too long to respond. I've heard of things like using XML format in order to pass it through instead, but I'm not quite sure how the hell I would do this really. I understand that you can pass attributes through XML with nested tags and stuff, but not sure how this helps or how I would even read it? I can understand that I can get the most recent message id, and send that back when checking for new messages, but I'm not sure how I can do this dynamically. I am going to attempt to stick an iframe at the bottom for submitting the message, so I don't have the ajax request for posting a message. Can anyone confirm that this will work better than using an ajax request? IE: <form name="blah" method="post" action="postmessage.php" target="iframe_name"> Instead of: <form name="blah" onsubmit="run_ajax_functions();"> Thanks, and I don't expect this to be solved very quickly. I'm hoping to expand my script to make it a bit cleaner, and faster :-) Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted October 17, 2007 Share Posted October 17, 2007 try to optimize your query/dbase.... that should help.. when theres no user inside the chatroom the rows should be deleted or else your table will be populate... Quote Link to comment Share on other sites More sharing options...
kratsg Posted October 26, 2007 Author Share Posted October 26, 2007 Bump o_o Quote Link to comment Share on other sites More sharing options...
Azu Posted October 27, 2007 Share Posted October 27, 2007 I'm not sure if I understood this right or not but... are you saying that every three seconds, EVERYONE in the chatroom downloads EVERYTHING in the chat room all over again? If this is the case then it can be sped up dramatically by only download new messages. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.