This method of remote scripting makes only minor changes to the page's (X)HTML. In fact, if you use JavaScript to bind event handlers no changes are needed.
The AJAX process is initiated by an event handler assigned to the onclick event of a link or the onsubmit event of a form. When remote scripting is not support, the link's href URL or the form's action URL provide an alternate response for the user. This is in keeping with unobtrusive JavaScript and graceful degradation.
JavaScript is coded to return true if it cannot run permitting the default action or false if it can run to prevent the default action. This is counterintuitive; however, it is not reporting the success of the process but a go/no-go for the default action, which is to request the href or action URL.
For these demonstartions, my default or alternate page simply, or not so simply, tells the user their browser doesn't support remote scripting. In a customer's Web application, this may be unacceptable. In that case, design the alternate page to provide the same functionality; albeit, without the performance of remote scripting.
In-line event binding is used in the following code snippets for illustration purposes. Better technique is to use attachEvent for IE or addEventListener for Firefox, et al. There is a nice piece of code at Adding An Event Handler that makes handling cross browser event binding a black box function.
Take a look at the HTML in-line bindings used in the examples.
HTML: Call RPC with a link <a href="page-for-noscript.html?data-value" onclick="return do_rpc(url, target_elem, null, ajaxResponseHandler);">link</a> Call RPC with a form <form name="rpc-form" id="rpc-form" action="page-for-noscript.cgi" method="get" onsubmit="return do_rpc(url, target_elem, this, ajaxResponseHandler);">
The only notable HTML feature is the event handler to trigger the RPC. In the markup above, options for an anchor (link) and for a form are shown.
The RPC function returns false when it CAN make the call to prevent the link or form's default action. It returns true when it CANNOT work to let the default page load. It is necessary to prevent the default action; otherwise, Firefox may throw an error.
In this code snippet, the function do_rpc initiates the remote scripting (AJAX) process. The function's arguments are explained next with the JavaScript.