开发者

Is it possible to send info from a webpage to a server without reloading?

开发者 https://www.devze.com 2023-01-20 08:59 出处:网络
I have found very little on this topic. I\'m trying to work out a way to synchronize pages cross-web without having to constantly reload pages to get new information, since the rate at which this woul

I have found very little on this topic. I'm trying to work out a way to synchronize pages cross-web without having to constantly reload pages to get new information, since the rate at which this would be necessary would cause the page to be outrageously slow.

The flow I'm thinking is this:

  1. User A alters info displayed on Page A.
  2. Page A sends info to server.
  3. Page B checks server for new info every 10ms or 100ms.
  4. Page B loads Page A's new info.

I can see AJAX as being sufficiently fast to retrieve info from the server, but have found no way to send data to a server without having to refresh every 10ms, 开发者_JAVA百科which, even using an iframe to avoid reloading the whole page, seems far too slow to me. Correct me if I'm wrong.

So my question is, is there any way of which I am unaware to do what I am attempting? I have seen methods involving a Java server applet, but that's a bit above my head at the moment. If that's the only way, I'll learn it, but I'd love to avoid that if possible.


There are two possible interpretations of what you wrote, the first which seems to be what you've actually said is that you want to know how to send data with an Ajax request, the second is that you want to know how to push unsolicited data from the server to the client.

  1. Ajax can easily add data to a request it makes - just add query-string parameters, or make a POST request and use XHR's send method

  2. Use comet - i.e. keep open a long-lived connection and send data only when there is something to send.


One of the possible way to implement what you want is to use Comet technology. For example - facebook uses it to interact with their servers.


If you are retrieving info fast using AJAX, then you are also sending info fast with AJAX...

GET requests are still telling the server something. For example, lookup RESTful web-services.


You could use updater of Prototype.

0

精彩评论

暂无评论...
验证码 换一张
取 消