jwk811 Posted October 26, 2006 Share Posted October 26, 2006 in a person to person chat room if you're using php you would need to keep reloading the page right? to make it so you dont have to load it can you use javascript? if so how would i do that.. and how exactly does the person to person chat work.. i have an idea.. well its actually pretty confusing.. would i need to be using asp, whatever that is? Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 26, 2006 Share Posted October 26, 2006 ASP is simply another server side scripting language (Microsoft's, actually) like ASP. In theory, a PHP chatroom would have to reload the page every few seconds to show you the new posts. However, if you use AJAX (client side HTTP requests), you could pull the newest posts every few seconds and simply tack it on to the tail of the chat content. That would be your best bet if you're wanting to use PHP for one. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 26, 2006 Author Share Posted October 26, 2006 when someone sends a message when they click send will it have to go to a script to get transfered over? and then redirected back to the page? how would that work? Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 26, 2006 Author Share Posted October 26, 2006 anyone? Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 26, 2006 Share Posted October 26, 2006 [quote author=jwk811 link=topic=112840.msg458192#msg458192 date=1161888845]when someone sends a message when they click send will it have to go to a script to get transfered over? and then redirected back to the page? how would that work?[/quote]Basically, you want a table that will hold the conversation. When someone hits "send", you'll want to send their entry to append to the end of the record. Of course, since they're the one sending the message, you can immediately display it on their screen with javascript. Then, you also want to have an HTTP request running to the server to grab any posts since the last request (usually somewhere around the ballpark of 8-12 seconds is a good gauge). If there are new entries, retrieve them via the HTTP request and update the display accordingly. Otherwise, it's the exact same logic behind every chatroom you've ever visited.Hope this helps. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted October 26, 2006 Author Share Posted October 26, 2006 thanks.. how can i use a HTTP request to catch the posts? its like this right? a chater sends a message and it appears on their screen on the bottom of the record and then the other chater must catch that post with the HTTP request and then display it onto their record that way? would i need to send the message through a script so i could get it into a variable? Quote Link to comment Share on other sites More sharing options...
R_P Posted October 26, 2006 Share Posted October 26, 2006 jwk, you're going to need at least a basic knowledge and understanding of JavaScript and the XMLHttpRequest element to make an AJAX chat. I am working on a flat-file based Ajax chat [url=http://ryan.crawford.com]here[/url] (second link from the bottom on that page). What I did was initiate the request element every time the form was submitted or enter key pressed. The request sent the line of chat to a PHP script which writes it too a flat file, while a different request element checks the flat file for changes. If a change happened, a line difference calculation occurs and PHP returns all lines submitted since the last change.If you want to circumvent the AJAX process, just split a page into two frames. In one frame, make a page that auto or meta-refreshes at a set interval, and in the other frame, create a basic form that posts information to a database whose action property is itself. Thats about as basic as PHP applications get. 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.