you’re on your way 4
31
next generation applications
We’ve still got plenty left to do, but let’s take a moment to see what’s already
done. Grab a cup of joe, let your brain relax, and review the rst two steps
in turning Katie’s report into an Ajax-powered app.
Reviewing what we’ve done
1
You added a new function, called createRequest(),
that creates a new request object. The code even works on
different browsers.
Create a new object to make requests to the server
2
You wrote another new function, called getBoardsSold().
This function used createRequest() to create a new
request object. Then, you set up a variable pointing to the
Ajax version of a PHP script on Katie’s server, initialized the
connection, and sent the request to the server.
Write a JavaScript function to request new board sales totals
We’ve got an Ajax-ready version
of the PHP script running on
Katie’s server now, too.
...and here’s what you did.
This was the original task
we had to complete...
You don’t need to submit the form
anymore... getBoardsSold() takes care
of making the request to the server.
<html>
<head>
<title>Boards ‘R’ Us</title>
<link rel=”stylesheet” type=”text/css”
href=”boards.css” />
</head>
<body>
<h1>Boards ‘R’ Us Sales Report</h1>
JavaScript
You’ll added this
JavaScript into the head
of your HTML.
createRequest()
now creates a new
request object.
<script>
var request...
function
createRequest()
{
...
}
</script ...