Thanks again. I've found a resolution after studying the $.post of AJAX. Here is how I've done it, assuming the <form> is placed inside a <div id="result">:
Code:
function sendForm() {
//.... some if-s for checking field content and return with "false" if not correct ...
$.post("mailform.php", { email : "someones@email.com" , subject : "Important subject" , message : "Some words about your concern..." })
.success(function(){
//...what to do if success;
$("#result").empty().append("Thank you!");
//...
})
.error(function(){
//...and what to do if failure;
$("#result").empty().append("Our apologies, there was an unexpected error. Our server is using Windows. :D");
//...
});
};
PHP Code:
mailform.php has only sending purpose:
<?php
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("ouremail@email.com", $subject, $message, "From:" . $email);
?>
Bookmarks