Java Reference
In-Depth Information
request.send();
}
 
function handleResponse(responseText) {
var response = JSON.parse(responseText);
 
if (response.available) {
alert(response.searchTerm + " is available!");
} else {
alert("We're sorry, but " + response.searchTerm +
" is not available.");
}
}
 
document.getElementById("usernameAvailability")
.addEventListener("click", checkUsername);
 
document.getElementById("emailAvailability")
.addEventListener("click", checkEmail);
</script>
</body>
 
</html>
Save this file in your web server's root directory. If you're using IIS for your web server, save it as
c:\inetpub\wwwroot\ch14 _ example1.html . If you're using Apache, you'll want to save it inside the
htdocs folder: path _ to _ htdocs\htdocs\ch14 _ example1.html .
You also need to place httpre q uest.js (the HttpRequest module) and the ch14 _ formvalidator.php
file (from the code download) into the same directory as ch14 _ example1.html .
Now open your browser and navigate to http://localhost/ch14_formvalidator.php . If everything
is working properly, you should see the text “PHP is working correctly. Congratulations!” as in
Figure 14-5.
figure 14-5  
Search WWH ::




Custom Search