The implementation of long polling is obtained recursively using xmlhttprequest. Once the page is added with this polling method, ajax requests in other places will not respond, for example, rolling to the bottom of the page to automatically load new articles. I checked the information. It is said that HTTP1.1 does not allow clients to create two http requests to the same server at the same time... the implementation of long polling is obtained recursively using xmlhttprequest. Once the page is added with this polling method, ajax requests in other places will not respond, for example, rolling to the bottom of the page to automatically load new articles. After checking the information, it is said that HTTP 1.1 does not allow clients to establish two http connections to the same server at the same time. How can this problem be solved?
Reply content:
The implementation of long polling is obtained recursively using xmlhttprequest. Once the page is added with this polling method, ajax requests in other places will not respond, for example, rolling to the bottom of the page to automatically load new articles. After checking the information, it is said that HTTP 1.1 does not allow clients to establish two http connections to the same server at the same time. How can this problem be solved?
It is said that HTTP 1.1 does not allow clients to establish two http connections to the same server at the same time.
This statement is incorrect.
In fact, you cannot access the page where the session is used on the same site concurrently. Because the session is locked when you access page A, page B can be executed only after page A is released. The solution is to release the session immediately after the session is used (php uses session_write_close to release the session lock)
Once, once again
Directly terminate the round-robin and return the current result (the round-robin result may be blank). Initiate an ajax request from other places to get the result, and then enable a round-robin (maybe I thought it was too naive ), or change the requirement.
In fact, server push is implemented by means of polling (this is generally the role ?), It is better to use socket, but it seems that its standards are not too clear. For details, please google. By the way, I also saw an article shared yesterday: Technical Design of the message push mechanism.
Recursion LongPolling. When the second request is enabled, the connection of the first request has been closed. There is actuallyOneAvailable channels. As long as the data service corresponding to the backend returns fast enough, a channel can be left empty.
For other solutions, place some Ajax in other domains and configure the server CORS or iframe.
How to submit ifame data
Iframe actually uses form to submit data to an iframe, and then returns a page in iframe, which contains a piece of js Code.
For example