HTML and CSS Reference
In-Depth Information
12.5 Using the Ajax API
As crude as it is, tddjs.ajax.get is now complete enough that we expect it to
be functional. We have built it step-by-step in small iterations from the ground up,
and have covered the basic happy path. It's time to take it for a spin, to verify that
it actually runs in the real world.
12.5.1 The Integration Test
To use the API we need an HTML page to host the test. The test page will make a sim-
ple request for another HTML page and add the results to the DOM. The test page
can be viewed in Listing 12.37 with the test script, successful _ get _ test.js ,
following in Listing 12.38.
Listing 12.37 Test HTML document
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<html lang="en">
<meta http-equiv="content-type"
content="text/html; charset=utf-8">
<title>Ajax Test</title>
<body onload="startSuccessfulGetTest()">
<h1>Ajax Test</h1>
<div id="output"></div>
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
<script type="text/javascript"
Listing 12.38 The integration test script
function startSuccessfulGetTest() {
var output = document.getElementById("output");
if (!output) {
Search WWH ::

Custom Search