jQuery in Action

The Form Plugin
281
if we check the Reset Form check box and click Test, we'll see how the
resetForm
option has been added to the method call.
The parameters detected by the server-side resource (by default, a
JSP
) are
shown last. We can compare the response with the Submitted data to make sure
that they always jive.
Run through various scenarios in the lab, changing form data and options to
suit your whims, and observe the results. This should allow you to get a good
understanding of how the
ajaxSubmit()
method operates.
In this section, we've assumed that we want to initiate a request using a form's
data under script control. We'd want to do this when an event other than a nor-
mal semantic submission event takes place--perhaps, clicking a button other
than a submit button (as in the lab page) or a mouse event such as the one we
used to invoke The Termifier requests in the examples of chapter 8. But some-
times, perhaps most often, the request submission will be the result of a normal
semantic submission event.
Let's see how the Form Plugin helps us set that up.
Hijacking a form's submission
The
ajaxSubmit()
method is great for those times when we want to initiate a
request under script control as a result of an event other than a form submission;
but, often, we want to take a conventional form submission and hijack it, sending
it to the server as an Ajax request rather than the usual full-page refresh.
Figure 9.4 The Results pane shows us the data sent to the request, the options used to invoke the
command, and the response body reflecting the data passed to the server resource.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.