HTML and CSS Reference
In-Depth Information
The XMLHttpRequest object's responseType property has been set to blob . Then
by using the response property to extract the binary data, the BLOB is passed to the
URL.createObjectURL method. The createObjectURL method gives the img element a URL
linking to the BLOB, and the image is displayed in the browser. For the inverse, the data can
also be submitted to the server as soon as it's serialized into a BLOB:
var xReq = new XMLHttpRequest();"POST", "saveImage.aspx", false);
xReq.responseType = 'blob';
Using the Form.Submit method
The form element of an HTML page is the area of the form that contains elements that are
typically input controls to gather information from users. The form element contains an action
attribute that tells the form where to submit its data. Submitting the data in this way submits the
entire HTML page back to the server for processing. However, another available mechanism is to
hook up to the form's submit event and handle the submission through JavaScript. This is useful
for submitting the form's data through an AJAX request so that users don't have to leave the cur-
rent page while the request is being processed. The form element at its simplest is as follows:
<form id="signupForm" action="processSignUp.aspx">
The form in this case will post its data to the processSignUp server page for processing,
which in turn should redirect users back to a confirmation page of some sort. The other
option for handling the form's submission is to wire up the event in JavaScript:
$("document").ready(function () {
$("form").submit(function () {
Iterating over all the form elements, capturing the data out of them, and constructing a
query string for use with an AJAX call would be possible inside the click event. The following
code reviews this concept:
$("form").submit(function () {
var fName = $("#firstName").val();
var lName = $("#lastName").val();
var qString = "Last Name=" + lName + "&First Name=" + fName;
url: 'processSignUp.aspx',
type: "POST",
data: qString,
success: function (r) {
return false;
Search WWH ::

Custom Search