views:

292

answers:

2

Is it possible to communicate and update data in a page without reloading, but without using the XMLHttpRequest object, AND sharing the same connection or socket every time (so, without closing the connection for every request)?

A: 

No.

You can change the content on the page with just Javascript, however if you want content from the server, you're going to have to use an XMLHttpRequest object.


Edit: Looking at the link above about "long polling"

My answer changes depending upon what you mean. Do you mean you don't want to use an XMLHttpRequest object at any level? Or do you mean that you don't want to have to use the raw XMLHttpRequest object.

Because in the end jQuery is going to use an XMLHttpRequest object. However if you just don't want to have to deal with the raw object, then you can use something like jQuery.


Looking at the answer above:

Okay, I understand what you were talking about...however the page you are linking is talking about something completely different.

Thomas
Hi. Well, the question arises because I'm using an embedded EZurio WiFi module and it seems to have a memory leak in its firmware because after about 2300 ajax posts generated by the client using XMLHttpRequest it crashes and it outputs a Malloc Fail error. So as a workaround I was thinking about using the same socket for all ajax communications.
apalopohapa
You're right - the page I linked to was opening a new XMLHttpRequest each time the server had anything to say. I've removed the link.
RichieHindle
+1  A: 

Make your server send back a "page" which is the usual HTML followed by a series of <script> tags that are output slowly over time. The whole thing works over the single socket that delivered the HTML page.

You can't communicate back from the client to the server that way - you'd need to make a new request to the server each time you did that, but with HTTP 1.1 that will reuse the same socket each time anyway.

RichieHindle