Java Reference
In-Depth Information
$.get(), but jQuery does provide the $.ajaxSetup() method. This method accepts an object containing
a number of properties to set options that affects all Ajax requests. One such option is the async option.
var options = new Object();
options.async = false;
$.ajaxSetup(options);
This code sets all Ajax calls to use synchronous mode. Again, only set this option to false when you
absolutely need it. Most (about 99.9 percent) of the time, you want to use asynchronous communication.
Let's revisit the form validator script using XMLHttpRequest from the previous chapter, and you'll
replace the HttpRequest module code with the Ajax capabilities of jQuery.
The $.get() method is quite simple to use and provides basic functionality. jQuery offers
much more advanced, low-level Ajax functionality, and you can fi nd out more at http://
docs.jquery.com/Ajax .
Try It Out Revisiting the Form Validator
Open your text editor and type the following code:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<title>Chapter 15: Example 4 with jQuery</title>
<style type=”text/css”>
.fieldname
{
text-align: right;
}
.submit
{
text-align: right;
}
</style>
<script type=”text/javascript” src=”jquery-1.3.2.min.js”></script>
<script type=”text/javascript”>
function checkUsername()
{
var userValue = $(“#username”).val();
if (userValue == “”)
{
alert(“Please enter a user name to check!”);
return;
}
var parms = new Object();
Search WWH ::




Custom Search