Skip to content Skip to sidebar Skip to footer

Jquery/php Mail Send The Easy Way?

Ok, to make long story short: JavaScript: jQuery('submit').click(function() { var address = jQuery('#mail').val(); var title = jQuery('#title').val(); var name = jQu

Solution 1:

You should use Ajax. Its a lot easier. ~~Here is a simple tutorial here on sending mail using PHP, Ajax, & jQuery:~~

[Send mail using PHP, Ajax and jQuery]

Edit: the link is no more available

it would look something similar to this:

var data = "address=" + address + "&title=" + title + "&name=" + name + "&mail=" + mail + "&message=" + message;
//or however u want to format your data

$.ajax({
     type: "POST",
     url: "sendmail.php",
     data: data,
     success: function(phpReturnResult){
          alert('Success: ' + phpReturnResult);
          jQuery(".email-us").html("<div id='email-sent'><p>Thank you for the message.</p><p>We will reply as soon as possible. PHP Script's return result: " + phpReturnResult + "</p></div>");     
     },
     error: function(errormessage) {
           //you would not show the real error to the user - this is just to see if everything is workingalert('Sendmail failed possibly php script: ' + errormessage);
     }
});

Also in your PHP file, you seem to used the mail function twice.

Post a Comment for "Jquery/php Mail Send The Easy Way?"