HTML and CSS Reference
In-Depth Information
them all to be considered in a radio button group, you would specify the value attribute to
differentiate them in the query string:
<input type="radio" name="gender" value="m"/>Male
<input type="radio" name="gender" value="f"/>Female
The jQuery.serialize method makes the code involved to generate a query string of the
parameters from a form much simpler to create and less error prone.
Thought experiment
Saving a form
In this thought experiment, apply what you've learned about this objective. You can
find answers to these questions in the “Answers” section at the end of this chapter.
In Objective 3.1, a customer survey was built. Extending this concept, how can you
use the XMLHttpRequest object to post the data captured in the form to the server?
Before submitting the form, how can you process server-side validation in real
time? Add validation to the form so that you can compare an email address entered
against a database of email addresses to ensure that it hasn't been used before.
Objective summary
Browsers provide native support via the JSON object to work with serializing and
deserializing JSON strings.
The JSON.parse method deserializes a JSON string into an object, and the
JSON.stringify method serializes an object into a JSON string.
By setting the XMLHttpRequest responseType property to the value 'blob' , you can
retrieve binary data.
By default, the form submit action sends the entire page to the server (based on the
action attribute) for processing.
Handling the submit event allows you to customize how the form data is posted to the
server.
The jQuery.serialize method provides a convenient shortcut to convert specified input
controls into a query string.
 
 
Search WWH ::




Custom Search