How does JavaScript handle messages in web pages
This article mainly explains "how JavaScript handles messages in web pages". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how JavaScript handles messages in web pages"!
This EventSource object is used to receive event messages sent by the server.
Now we create an HTML document called " demo_sse.html" and place it in the project directory where the " server_time.php" file is located. This HTML document simply receives the current time reported by the Web server and displays it to the user.
The code is as follows:
Using Server-Sent Events
_window.onload = function() {
var source = new EventSource("server_time.php");
source.onmessage = function(event) {
document.getElementById("result")[xss_clean] += "New time received from web server: " + event.data + "
";
};
};
At this point, I believe that everyone has a deeper understanding of "how JavaScript handles messages in web pages", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!