SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 179 | Next

Deepak Vohra

"Ajax in Oracle JDeveloper"

Specify the
third parameter of the open() method as true for asynchronous
requests.
10.7 Sending an Ajax Request with Yahoo Search Web Services 213
xmlHttpRequest.open(???GET???, url, true);
Register a callback function that is to be invoked when the request state
changes using the onreadystatechange property of the
XMLHttpRequest object.
xmlHttpRequest.onreadystatechange=processRequest;
Send the XMLHttpRequest request using the send() method with
null as the parameter to the method, the request method being GET.
xmlHttpRequest.send(null);
In the callback function check if the request is complete and the request
status is ???OK??? and invoke the JavaScript function
processResponse() to update the web page with the Web Service
response. A readyState value of 4 corresponds to a completed request
and HTTP status code 200 corresponds to ???OK??? request status.
if(xmlHttpRequest.readyState==4){
if(xmlHttpRequest.status==200){
processResponse();
}
}
}
To the input form add a
element searchResults to display
the search results. In the processResponse function obtain the XML
response with the responseXML attribute of the XMLHttpRequest
object.
var xmlMessage=xmlHttpRequest.responseXML;
Next, update the searchResults div with the Web Service
response. Retrieve the searchResults element with
getElementById method.
var
searchResults=document.getElementById(???searchResults???
);
Construct an HTML string with which to update the searchResults
div.


Pages:
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184