我有一個接觸形式發送它與一個Ajax請求的PHP腳本的信息。現在我喜歡實施谷歌的「我不是機器人」recaptcha。克-reCAPTCHA的響應與AJAX
的問題是,我不知道如何運送G-reCAPTCHA的響應與阿賈克斯。 我怎麼能證明它,結果發送到send_contactrequest_process.php?
<div class="kontakt-container">
<form class="kontakt-form" id="kontakt-form" method="post">
<input type="text" name="firstname" id="contact-form-firstname" placeholder="Vorname (erforderlich)" class="kontakt-form-input" minlength="2" required="required" data-msg="Du musst dieses Feld ausfüllen">
<input type="text" name="lastname" id="contact-form-lastname" placeholder="Nachname (erforderlich)" class="kontakt-form-input" minlength="2" required="required" data-msg="Du musst dieses Feld ausfüllen">
<input type="tel" name="telephone" id="contact-form-telephone" placeholder="Telefonnummer" class="kontakt-form-input">
<input type="email" name="email" id="contact-form-email" placeholder="E-Mail (erforderlich)" class="kontakt-form-input" minlength="10" required="required" data-msg="Diese Email-Adresse ist ungültig">
<textarea class="kontakt-form-message" id="contact-form-message" required="required" data-msg="Was möchtest du uns mitteilen?"></textarea>
<div class="g-recaptcha" data-sitekey="MY KEY"></div>
<div class="kontakt-form-submit" id="kontakt-form-submit">senden</div>
</form>
<p class="kontakt-form-success-message">Vielen Dank für Deine Nachricht.</p>
</div>
if($("#kontakt-form").valid()){
var firstname = $('#contact-form-firstname').val(); //Validierung der Form-Daten
var lastname = $('#contact-form-lastname').val();
var email = $('#contact-form-email').val();
var telephone = $('#contact-form-telephone').val();
var message = $('#contact-form-message').val();
$.ajax({ //AJAX request
type: "POST",
url: "../../../include/process/send_contactrequest_process.php",
data: {firstname: firstname, lastname: lastname, email:email, telephone:telephone, message:message},
success: function() {
$('.kontakt-form-success-message').css("display","inline");
},
});
}