Java Reference
In-Depth Information
function checkUsername(e) {
e.preventDefault();
var userValue = $("#username").val();
if (!userValue) {
alert("Please enter a user name to check!");
return;
}
makeRequest({
username: userValue
});
}
And the checkEmail() function:
function checkEmail(e) {
e.preventDefault();
var emailValue = $("#email").val();
if (!emailValue) {
alert("Please enter an email address to check!");
return;
}
makeRequest({
email: emailValue
});
}
You can also eliminate the parms variable in both of the functions, as shown in this
solution. Just pass the object literal directly to makeRequest() to make your code more concise.
Chapter 17
exercise 1 Question
Modify the answer to Chapter 14's Question 2 using Prototype. Also add error reporting for when
an error occurs with the Ajax request.
exercise 1 Solution
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 17: Question 1</title>
<style>
.fieldname {
text-align: right;
Search WWH ::




Custom Search