AJAX and Client-Server Architecture with JavaScript

前端 未结 5 539
误落风尘
误落风尘 2021-02-03 13:00

I have to program websites, but I rather don\'t like the static HTML nature. I prefer more of a client-server architecture.

Now I\'ve figured, that with XMLhttp, you can

5条回答
  •  逝去的感伤
    2021-02-03 13:46

    The client has to tell the server when the client-user begins typing. You've got a couple options here.

    1. Frequent requests from the server for the latest activity. This would be taking place for each user involved in the chat. The same request could be used to send user-specific activity to the server as well: "Jonathan is typing..."

    2. Long-polling. This essentially requests information from the server, and the server keeps the connection opened until it has something to send back. So your requests are minimized, but your connections stay opened longer.

    Depending on your traffic, type of data being transmitted, server-environment, and many other factors, one of these options may shine more than the other.

提交回复
热议问题