tags:

views:

13

answers:

1

In this page, when you submit the form the page seems to stay as it is and it just shows a message at the top of the page saying that the message was sent.

The only part I understood was the following code:

jQuery(function() {
var returnMessage = ['I got the message! I will get back to you as soon as I can.'];

    jQuery('body').showMessage({

      'thisMessage':  returnMessage,
      'className':  'success',
      'opacity':  95,
      'displayNavigation': false,
      'autoClose':  true,
      'delayTime':  4000

      });
    });

I know that the code above makes the message appear at the top of the page.

But I can't see how is this Javascript code connected to the form.

Can anyone explain that to me?

Thanks!

+2  A: 

It looks like the page uses the showMessage jQuery plugin. This plugin simply displays a message at the top, it has no connection with a form. When you navigate to the link you provided there is no need to submit a form to see the message.

The way it works is that you fill the form at the Contact page and once you submit it you are redirected to the Confirmation page which simply contains the notification message at the top.

Darin Dimitrov
@Darin Dimitrov Submitting the form triggers that message inside the [] brackets.
janoChen
@janoChen, submitting the form triggers a request to the web server which redirects to the Confirmation page. This confirmation page contains the message. So technically speaking submitting the form doesn't trigger any message at all.
Darin Dimitrov
@Darin Dimitrov So the message is automatically triggered in this new confirmation page!
janoChen
@janoChen, yes the message is triggered when the confirmation page is displayed.
Darin Dimitrov
@Darin Dimitrov But this means that the message will be displayed each time I reload the confirmation page. Is there a way of avoiding this?
janoChen
@janoChen, yes each time you reload the confirmation page the message will be there. What you could do instead is set a server side variable which indicates if the message should be shown and based on it's value you include or not the call to `.showMessage`. Another alternative is to use AJAX and in your success handler show the message (in this case you won't be navigating away from the contact page).
Darin Dimitrov
@Darin Dimitrov Thanks, I'll try those alternatives.
janoChen