jQuery and Form2Mail

/ Published in: jQuery
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.