HTML and CSS Reference
In-Depth Information
chapter 11
n n n
Using the Communication API
and Web Sockets
So far in this topic, you've learned about HTML5 features that require no server-side communication.
Although you used some techniques such as jQuery $.ajax() to send and receive data between the client
and the server, doing so wasn't an integral part of the HTML5 feature being discussed. In this chapter,
however, you learn about a few HTML5 features that are specifically designed to facilitate communication
between the client browser and the server. Using these features, you can pass data to and from web pages
from the same web application or from different applications. Additionally, some of these techniques
provide one-way (client to server) communication, and others provide two-way (client to server and server
to client) communication. Specifically, you learn about the following:
• Cross-document messaging and Cross-Origin Resource Sharing (CORS)
• Using the postMessage API to send data to documents from different web
application
• Using the new XMLHttpRequest Level 2 features to make GET and POST requests
• Notifying the client using server-sent events
• Performing two-way communication using Web Sockets
Understanding Cross-Domain Communication
A web application often needs to perform one of the following two kinds of communication:
• A web page may want to communicate with another web page from the same web
application.
• A web page may want to communicate with another web page belonging to some
another web application.
Performing the first type of communication is relatively simple because there are no restrictions
enforced by the browser on such communication. Additionally, JavaScript-based libraries such as jQuery
are readily available for performing this type of communication. However, things become tricky when you
wish to communicate to web pages from a different web application.
Search WWH ::




Custom Search