473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

persistent ajax/comet

rohypnol
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 2867
pbmods
5,821 Expert 4TB
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 onreadystatechange() 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
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
17
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
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...
1
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...
8
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...
3
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...
3
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...
13
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,...
6
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.