Click here to Skip to main content
14,836,641 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
On an page, I used the jQuery Form wizard from, and now that I have (almost) everything configured properly, I'm having the problem of not knowing how to handle the submit event.

I'm new to jQuery/AJAX and the last time work had me working on pages was a few years back.

Here's the script tag defining the form parameters in the page:
<script type="text/javascript" language="javascript">
$(function() {
   $("#RegistrationFormEn").formwizard({ //wizard settings 
       formPluginEnabled: true, //Ajax is used to post the form to the server
       validationEnabled: true, //The Validation plugin is used for validating the form at each step
       focusFirstInput: true // puts focus at the first input on each step
       //validation settings
       messages: { email: "Invalid email (custom message)"} // custom message shown when the email is invalid
      // form plugin settings
     success: function(data) { // called when the form has been submitted correctly to the server
         $("#status").fadeTo(500, 1, function() { $(this).html("You are now registered!").fadeTo(5000, 0); })
    /*beforeSubmit: function(data) { // called just before the form is submitted
         alert('data being sent to the server' + data.hotelOption);
    dataType: 'json',
    resetForm: true,
    textSubmit: 'Register'

and the code in my js file:
$(document).ready(function() {
//show the attach visa
$("#VisaHelpNeeded").click(function() {
//hide the attach visa
$("#VisaHelpNotNeeded").click(function() {
//show the help in getting visa
$("#VisaIsRequired").click(function() {
//hide the help in getting visa
$("#VisaIsNotRequired").click(function() {

$().ajaxStart(function() {
    // 'this' is the document object
    alert(this === document);
    alert('caught the ajax!');

$().ajaxForm(function() {

$() {
   alert('caught the submit');

You can see that the last few methods were just traps to see which method gets fired. I'm baffled to see that none of them apparently caught the submit.

Now one question is how to handle the submit event? Because the next step is to try and have the data sent to a webservice that would then pipe everything into a DB and send an email (I have no problem with the webservice, its catching the submit that's giving me a hassle).

All help is very much appreciated, so a very big thank you in advance.
Updated 9-Jul-10 7:49am
Mustafa Ismail Mustafa 9-Jul-10 13:59pm
Ah, thank you Chris. Looks much better now.

1 solution

You're overthinking it! ;)

Data's already going to the server, you just need to catch it now.

It will go back to the same script that was used to display the form (so, like, reserveration.aspx if that's the name of your page) if you don't specify the action in the form.

Attach Firebug to the session and you should see the form getting sent to the server.

All you have left is the webservice, which will have to accept the data in JSON format (per your settings).

Mustafa Ismail Mustafa 10-Jul-10 4:15am
Thanks, that helps in explaining it, but would you be able to offer a sample? I'm sorta lost.

Seriously, thank you.
Mustafa Ismail Mustafa 10-Jul-10 4:17am
Reason for my vote of 5
For explaining what the heck is going to a flailing duck, me. :)
Mustafa Ismail Mustafa 10-Jul-10 5:41am
And another thing. It occurred to me that I have to not only store the info in a DB, but that I also have to send an email automatically. Can I still do that your way? What event gets fired? Where can I handle the post? I'm lost.
TheyCallMeMrJames 10-Jul-10 11:19am
Are you open/able to use MVC? Makes this kind of thing trivial and I have a ton of examples posted already I could link to. If not, I can whip up a sample for you in ASP.NET 2.0 or 3.5. Let me know!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900