getElementById(???validationMessage???);
Replace the getElementById() function with prototype function
$().
var validationMessage=$('validationMessage');
In the non-prototype version an XMLHttpRequest object is created
with the XMLHttpRequest constructor or the ActiveXObject
constructor. The callback method is registered with the
XMLHttpRequest object and the HTTP request sent to the server. The
callback method is invoked when the request state changes and when the
request is complete the HTTP response is processed.
var xmlHttpRequest=init();
function init(){
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
return new
ActiveXObject(???Microsoft.XMLHTTP???);
}
}
xmlHttpRequest.onreadystatechange=processRequest;
xmlHttpRequest.send(null);
function processRequest(){
if(xmlHttpRequest.readyState==4){
if(xmlHttpRequest.status==200){
processResponse();
}
}
}
The prototype library provides Ajax.Request class to send an
XMLHttpRequest request. Define a variable for servlet url and a
variable for url parameters.
var catalogId=$F('catalogId');
var url = 'validateForm';
var pars ='catalogId='+catalogId;
3.4 Configuring Prototype in AJAX Web Application 53
Create an Ajax.Request object with the servlet url. Set the options
property method to ???get??™. Specify the parameters options property
and set the asynchronous property to true.
Pages:
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68