Question

I am just getting started creating an AJAX application using server side push. I am using Grizzly Comet on Glassfish V2. Almost all the sample applications use IFrames for updating content on the client side. I want to stick to using JavaScript only. Are there any such sample applications (preferably ones that do not use a JavaScript library)?

Was it helpful?

Solution

The point about the push is that the HTTP request never ends. Not all client implementations handle that correctly. As I see it, it's possible to do it with pure javascript in Firefox with its extensive API, but the XMLHTTPRequest object would timeout and would not be able to stream you the content.

IFrame is good, you could also try the object tag if its about standard compliance.

Before XMLHTTPRequest and Ajax had no name, we used to get data from the servers through IFrames.

OTHER TIPS

This is how I figured out how to do a push with just javascript and php.

Have javascript do an initial call and load content into a div. Then have the javascript call back to the php and have the php sleep until it see there is a new update. Then send out the data to everyone and call back to php and sleep again.

This allows for long polling and fewer calls back to back. I personally put a time of 5 mins to 30 mins on the php script.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top