execute(sql);
response.sendRedirect(???catalog.jsp???);
stmt.close();
conn.close();
} catch (javax.naming.NamingException e) {
2.5 Processing an Ajax Response 35
response.sendRedirect(???error.jsp???);
} catch (SQLException e) {
response.sendRedirect(???error.jsp???);
}
}
}
2.5 Processing an Ajax Response
In this section the Ajax XML response is retrieved and the input web page
updated to indicate the validity of the Catalog Id value and the input fields
are autocompleted if the Catalog Id is not valid. If the readyState
property value is 4, which corresponds to a completed
XMLHttpRequest, and the status property value is 200, which
corresponds to HTTP status ???OK???, the processResponse() function
gets invoked. In the processResponse function, obtain the value for
the responseXML property.
var xmlMessage=xmlHttpRequest.responseXML;
The responseXML object is an XML DOM object. Obtain the value
of the
element using
getElementsByTagName(String) method.
var
valid=xmlMessage.getElementsByTagName(???valid???)[0].fir
stChild.nodeValue;
If the
element value is true, set the HTML of a div element
in the Catalog Id field row to ???Catalog Id is Valid???. Enable the submit
button in the input form.
if(valid==???true???){
var
validationMessage=document.getElementById(???validation
Message???);
validationMessage.innerHTML = ???Catalog Id is Valid???;
document.
Pages:
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55