Topic: ajax and javascript (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28507" title="Pages that link to Topic: ajax and javascript (Page 1 of 1)" rel="nofollow" >Topic: ajax and javascript <span class="small">(Page 1 of 1)</span>\

 
kudos
Nervous Wreck (II) Inmate

From:
Insane since: Dec 2004

posted posted 10-06-2006 09:44

Hi, I am currently making an ajax based application. Anyway, once a second I need to get som information from my webapplication (something spitting out xml). I have the following question, right know I do the following, poll info from the webapp every second (through the setInterval method) but I don't like this approach. Is there anyway to do a post from the webapp to the javascript/ajax application? Or do I have to stick to the polling approach?

-kudos

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-06-2006 10:10

Well, on one hand, you do have to stick to the polling.

But your webapp maybe doesn't need to answer right away.
For example, it could find that it has nothing to say, sleep in one second stretches
till it has something to say (or a maximum timeout has occured) and then say what ever
it has to say.

There are also systems that hold the communication channel open, so the server knows
who it's talking to - but they're not strictly ajax and I believe need alternative http servers
(or at the very least an apache plugin. Darn what was that stuff called again?)


But then again, I believe an ajax app polling once a second is somehow innappropriate
- what are you planning on doing?

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

posted posted 10-06-2006 10:20

Seems like what you need is COMET or Server Sent Events .

Regarding COMET you should check the post on Ajaxian: Comet: A New Approach to Ajax Applications. It features some interesting links.

SSE is a, I mean THE, standard way to implement a COMET application. AFAIK only Opera9 and FireFox2 have implemented SSE yet. Too bad because this approach is really clean. About a month ago, some guys at work have implemented a chat application using SSE and Python in no time. We kept the chat live for a few weeks and it never exceeded 2% of CPU usage even though the URL appeared on Digg and Reddit.


However, COMET or SSE, the communication from Client to Server still needs XHR or older tricks ( who said IMG or SCRIPT tag with crafted URLs ? )


What kind of application are working on for the clients have to be updated every second ?

kudos
Bipolar (III) Inmate

From:
Insane since: Dec 2004

posted posted 10-06-2006 10:57

Hi.

First, thanks for replies. What kind of app need to get updated for each second (or atmost 3 seconds)? Im working on a ajax interface to some switchboard software. If I had some way to let the webapp (which is the interface between the web and switchboard) post something to the client (i.e the javascript stuff) that would solve my problems...

Thanks for the links Poi, and how do you like Norway?

-kudos

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 10-06-2006 13:21

Comet, that was the name esaping my memory .



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu