In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "HTML5 server sending event instance analysis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The HTML5 server sends an event (server-sentevent) that allows a web page to get updates from the server.
Server-Sent event-one-way messaging
The Server-Sent event means that a web page automatically gets updates from the server.
It was possible to do this in the past, as long as the page had to ask if any updates were available. Updates can arrive automatically by sending events through the server.
Examples: Facebook/Twitter updates, stock price updates, new blog posts, race results, etc.
Browser support
InternetExplorerFirefoxOperaGoogleChromeSafari
All major browsers support sending events from the server, except for InternetExplorer.
Receive Server-Sent event notifications
The EventSource object is used to receive event notifications sent by the server:
Example
Var source=new EventSource ("demo_sse.php")
Source.onmessage=function (event)
{
Document.getElementById ("result") [xss_clean] + = event.data + "
"
}
Instance resolution:
Create a new EventSource object, and then specify the URL of the page that sends the update (in this case, "demo_sse.php")
Every time an update is received, an onmessage event occurs
When the onmessage event occurs, push the received data into the element whose id is "result"
This is the end of the content of "HTML5 Server sending event instance Analysis". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.