Main Page

Cross-Browser Approach

} else {
alert(“Proxy not available.”);
is called in this function, another thread is started to make the Web service call. The
result is passed into the
object. This function is called when the user clicks the Get
Temperature button (this example uses the same HTML page as the previous examples).
The way this code executes is very non-linear (see Figure 17-2), but it gets the job done.
Figure 17-2
A Cross-Browser Approach
Once again, the differences in how browsers access Web services are so vast that you can’t create a cross-
browser method using the current browser functionality. But because Web services are nothing more
than standard HTTP requests with a special format, it’s possible to create a cross-browser approach
using the XML HTTP request object. For this to work, you use the browser detection script and the script
creating a
constructor for Internet Explorer explained earlier in the book.
The WebService object
Each Web service is unique, so how can you possibly develop a standard way to use them? The answer
is to create a generalized template object definition that can be overridden to make it more specific. This
template object is called
and is defined this way:
2 var oProxyCreateCallback = {
onLoad: function(...) {
function createProxy() {
var oGetTempCallback = {
getTempCallback: function() {
function callWebSer vice() {
Web Services
20_579088 ch17.qxd 3/28/05 11:42 AM Page 525

JavaScript EditorFree JavaScript Editor     Ajax Editor