views:

22

answers:

1

I just finished the basic design structure for my contact page without flash; it's located here.

Can anyone suggest the best approach for making a confirmation script (inside a DIV) without reloading the page (preferably with jQuery). I want to replace the content in the main WRAP with new content (just text) confirming the email was received.

Any suggestions?

A: 

First of all I don't believe you can notify the user that the mail was actually received (at least not in a trivial way). But you can notify that it was sent. For this with jQuery you can send the contact info via AJAX and then show the response in the DIV. May be something like this:

$.ajax({
   type: "POST",
   url: "sendMail.php",
   data: $('#contactForm').serialize(),
   success: function(msg){
     $("#responseDiv").html(msg).show();
   }

});

Of course this is assuming that your server sends the for with "sendForm.php" and that your contact form is wrapped with a <form> with "contactForm" as an id. The server should respond with the text to show within the div. If the message was sent or not.

Hope this helps.

References: Ajax help for jQuery

p1r0
Thank you.. yes helps in the right direction!
Erik