Java Reference
In-Depth Information
summarY
This chapter introduced you to Ajax, and it barely scratched the surface of Ajax and its many uses:
You looked at the XMLHttpRequest object, and learned how to make both synchronous and
asynchronous requests to the server and how to use the onreadystatechange event handler.
You built your own Ajax module to make asynchronous HTTP requests easier for you to
code.
You used your new Ajax module in a smarter form, one that checks usernames and e‐mails
to see if they are already in use.
You saw how XMLHttpRequest breaks the browser's Back and Forward buttons, and
addressed this problem by rebuilding the same form using a hidden iframe to make requests.
You looked at some of the downsides to Ajax, including the security issues and the gotchas.
exerCises
You can find suggested solutions for these questions in Appendix A.
1. Extend the HttpRequest module to include synchronous requests in addition to the
asynchronous requests the module already makes. You'll have to make some adjustments to
your code to incorporate this functionality. (Hint: Create an async property for the module.)
2. It was mentioned earlier in the chapter that you could modify the smart form to not use
hyperlinks. Change the form that uses the HttpRequest module so that the Username and
Email fields are checked when the user submits the form. Listen for the form's submit event
and cancel the submission if a username or e‐mail is taken.
 
 
Search WWH ::




Custom Search