Hey guys I'm trying to make a contact form where people can contact me.
What I want want is something that people could fill, and if they click "Send", they get a message like "Mail has been sent", so that they don't get redirected to the PHP site.
Unfortunately, it's not working for me. If I click on "Send", it shows me the script. So I'm not sure if the AJAX code is correct. Could anyone help me?
$(document).ready(function() {
$("#kontakt").submit(function() {
if($("von").val() == "" || $("mail").val() == "" || $("nachricht").val() ==""){
$("#response").html("bitte fülle alle felder aus!");
} else {
$("#response").("Lade...");
$.ajax({
type:"POST",
url:"senden.php",
data:"von=" + $("von").val() + "&mail=" + $("mail").val() + ="&nachricht=" + $("nachricht").val(),
success: function (msg)
{
$("#response").html(msg);
}
);
});
}
return false;
});
});
<form method="post" action="senden.php" id="kontakt">
<h3 class="title">Nur nicht schüchtern !</h3>
<input type="text" name="von" placeholder="Name" id="von">
<input type="text" name="mail" placeholder="E-mail" id="mail">
<textarea name="message" placeholder="Nachricht" id="nachricht"></textarea>
<input id="submit" type="submit" value="senden"></submit>
</form>
<div id="response"></div>
I put it also on jsFiddle http://jsfiddle.net/PqKFb/