Posted By

creativeboulder on 12/13/10


Tagged

form javascript post jquery contact form2mail


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sjacunningham
creativeboulder
withremote


jQuery and Form2Mail


 / Published in: jQuery
 

This is some very basic jQuery to post from a comment form on a website. I would probably change the .click to .bind("click",) and for different sites I add a success message. This code works with a basic form with text inputs named #name and #email and a textarea named #comments.

Very basic.

  1. $("#sendmessage").click(function() {
  2. var name = $("input#name").val();
  3. var email = $("input#email").val();
  4. var comments = $("textarea#comments").val();
  5. var dataString = 'Name=' + name + '&Email=' + email + '&Comment=' + comments;
  6. $.ajax({
  7. type: "POST",
  8. url: "lib/form2mail/form2mail.php",
  9. data: dataString
  10. });

Report this snippet  

You need to login to post a comment.