Reading Server Data
We begin our exploration of Ajax with the basics: using the XMLHttpRequest object to retrieve and display information from a server.
To get the job done, we’ll use Scripts 13.1 (HTML) and 13.2 (JavaScript). There are two possible files that can be read: the XML file that is shown in Scripts 13.3 and the plain text file that is Scripts 13.4.
To request server data:
1. | var xhr = false; |
2. | function initAll() { document.getElementById("makeTextRequest").onclick = ... |
Get JavaScript and Ajax for the Web: Visual QuickStart Guide, Seventh Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.