AJAX不断寻找服务器更新?使用Javascript服务器、AJAX、Javascript

2023-09-10 19:42:32 作者:手捧鲜花

我有一种情况需要随意更新网页上的显示。我想这样做是AJAX,但我不知道如何做到这一点除了做

I have a situation where a display on a webpage needs to be updated at random. I am wanting to do this in AJAX but am not sure how to do this other than to do a

while(true) { ajaxFunction(); sleep(1) }

类型的事情。

Type thing.

这里的问题是,网页需要被更新很快就更改了服务器,但这些更改可能发生非常零星,有时从来没有。

The problem with this is that the webpage needs to be updated very quickly on a change to the server, but the changes could happen very sporadically sometimes never.

编辑:这是用一个UIWebView的iPhone应用程序,是有可能使用iPhone的推送通知使用JavaScript接口

This is an Iphone application using a UIWebView, is it possible to use the iPhone's push notification to interface with the javascript?

谢谢!

推荐答案

我觉得你描述什么是的彗星并有一对夫妇插件jQuery的:

I think what you're describing is Comet and there are a couple of plugins for jQuery:

HTTP://$c$c.google.com/p/jquerycomet/

http://plugins.jquery.com/project/Comet