Chapter 6. Web Remoting
NOW THAT WE’VE SEEN HOW AJAX APPS CAN MANIPULATE THE DISPLAY, IT WOULD BE USEFUL IF THEY could use that capability to show data arriving from the server. We’d also like to accept input and upload it to the server. The Web Remoting patterns let JavaScript directly issue calls to the server. The point is to let the browser make a query or upload some data, without actually refreshing the page.
The first pattern is Web Service, which explains how the server side exposes functionality to be accessed by the browser.
The remaining patterns are the most useful and most common
mechanisms for web remoting.[*] XMLHttpRequest Call is a clean way
for the browser script to invoke and catch responses from the server.
IFrame Call provides a similar use by exploiting IFrame
functionality. HTTP Streaming, also known as “Push” (or “Comet”), allows the server to
continue streaming new data down the pipe, without the browser having to
issue new requests. On-Demand JavaScript is a fairly broad-scoped pattern and is included in this
section because one style, Script Tag
Generation, is a distinctive technology that’s becoming a
popular way to directly access external domains.
Of the four techniques, XMLHttpRequest Call
is the cleanest, because XMLHttpRequest is specifically designed for
web remoting. Nevertheless, all of the techniques are effective, and
each has a certain set of situations where it’s the superior choice. See
the "Alternatives" section
for XMLHttpRequest Call ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access