DHTML RPC allows JavaScript on a webpage to call a remote server without a page reload. Although techniques for RPC have been around almost since the beginning of JavaScript (DynAPI, Brent Ashley), there has been a recent resurgence in popularity coincident with the emergence of several relatively compatible modern DHTML browsers (Mozilla, Safari, Opera, IE) along with many high profile example applications (links to apps, perhaps just google search on XMLHttp/RPC or something).
There are an unfortunately diverse variety of ways to approach DHTML RPC, each with their own unique advantages and disadvantages. For our purposes here, we will focus only on the most robust, flexible, and compatible solutions available for the public internet today.
Uses the XMLHttpRequest object, which has become a de-facto standard, to make a synchronous or asynchronous web request. Both GET and POST HTTP methods are widely supported. Although originally designed for XML, any textual format can be retrieved through the responseText property.
More Information
Return XML example
Return HTML example
Return JavaScript example
The DOM is used to dynamically create a new <SCRIPT>
element with a remote SRC
attribute. When the element is appended to the document, the browser dutifully downloads and executes the returned JavaScript. Two-way communication is possible by targeting a server-side script and appending querystring parameters.
Open to contributors...
A unique property of the Flash plugin is it's ability to maintain long-term two-way communication with a server via socket connections. A downside is that two-way communication with the DHTML host page is difficult in all platforms. Research will need to be done to see if this should be included or if Push covers it.
Also open to contributors...
Though DHTML RPC can radically improve the user experience through increased responsiveness, most implementations simultaneously negate those improvements by breaking the back button and the URL bar. These are critical components of the web browsing UI and must be preserved.