473,799 Members | 3,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

persistent ajax/comet

rohypnol
54 New Member
Hi!

Is there a way to have a persistent connection between the client and the server, through which to pass data from one to the other? For example, having a webchat application that connects to the server using the XMLHttpRequest javascript object and keeps the connection alive until the page is closed (consider a "perfect" environment where it's not interrupted by 3rd party) or until the client decides to disconnect. How would the client pass data to the server and viceversa?

The best method I know for this is to have a connection which is reopened after the client receives information, in order to use the POST method to pass a response.

After reading the first paragraph, I guess my question would be: can the client respond to information pulled from the server using the same XMLHttpRequest object?

I'm interested in both the PHP and JavaScript, if this is possible.

Regards,
Tom
Dec 27 '07 #1
1 2893
pbmods
5,821 Recognized Expert Expert
Heya, Tom.

This is not possible. HTTP is stateless by nature; as soon as the request is fulfilled, the connection is terminated.

In the situation you are describing, you can simply create a new instance of an XMLHttpRequest object and send() it as soon as the current XMLHttpRequest instance's onreadystatecha nge() fires.

It doesn't matter which instance you use; it's a new request as far as the server is concerned.

The browser will pass a session ID with the request, so you can use $_SESSION to store User-specific information.
Jan 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
6159
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
17
13210
by: petermichaux | last post by:
Hi, Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server. Thanks, Peter
3
5914
by: petermichaux | last post by:
Hi, I am trying to put together the last major pieces of my project's puzzle. This is more website/client-side architecture than JavaScript syntax but I hope this is a good place to ask. I'm a little stumped with which direction to take and advice would be greatly appreciated. I think this is a generally interesting problem but I haven't seen a post this long here before :S I have developed half of the admin interface for an e-commerce
1
2429
by: jason.m.ho | last post by:
Hello, I want to make a chat system using the Comet push-style technology. I already wrote a poll-based one using Ajax, but I want to learn how to do server-pushes. Does anyone know of a good website that can show me how to do this? Or recommend a good library/framework to use? Thank you! Jason
8
2113
by: jason.m.ho | last post by:
>From the common user perspective (like my grandma), why would they care if its a java applet or an ajax application? Say I want to make a chat system on my website...If i'm doing really involved Comet push-style data communication, and rendering everything using DHTML, why would users prefer that over a java applet? Moreover, say I use a java applet to transfer data through a socket connection, then use DHTML to display the data, so...
3
2089
by: kariach | last post by:
Hello, I am writing a web app that collects some user input and an optional image filename. When the user clicks submits, I use an asynchronous XML HTTP call to a backend asp.net handler to process the input. I have not been able to figure out clean way to upload a file in this setup - Can someone offer some help? thanks, Simon
3
19885
by: markus.rietzler | last post by:
i want to do (multiple) file upload(s) and display a progress bar. with firefox and safari it is no problem at all. only IE makes some problems. my script is based on ajax-uploader, which can be found at www.srmiles.com/freestuff/ajax_file_uploader/ . you can do multiple file uploads. each upload will have it's own "form"-tag, so that each file is uploaded for its own. could be a good solution if there are "big" uploads.
13
4007
by: Marvin Zhang | last post by:
Hi, I'm not familiar with web programming, but I have a problem here. I have a page. When a user click one button on it, I will use AJAX to request a PHP script which will do a bunch of tasks, asynchronously. These tasks might take long time so I want to keep the user informed of the progress. The problem is that only the PHP script knows the progress, how can the web page gets these information from PHP script?
6
1737
by: lihao0129 | last post by:
Hi, friends, I am hoping to write a chatroom with the AJAX methodology. I knew I can set periodic refreshment from the client-side code and make the input from any visitor get updated to all others. But I think this method is very low efficient since I have to contact the server in a very short time interval.. Is there any more practical ways to do this with AJAX? Many thanks for your suggestions and time..
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10259
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.