Hi there,
I'm working with MODx just for some weeks now, but I'm amazed by it's capabilities. Sadly there are still some questionmarks:
I got a problem with a form. The form itself works fine, the JS validation works just fine and the form gets sent and gets received. The problem is that the user doesn't get any confirmation after the form is sent. Of course I could rebuild the form with FormIt but I need a confirmation without a page refresh and I need the form gone after it got sent.
This is the AJAX part, which calls a blank resource called "ajax-form" with just a snippet call on it.
$(document).ready(function() {
$("#reservation-form").validationEngine({
ajaxSubmit: true,
ajaxSubmitFile: "ajax-form",
ajaxSubmitMessage: "Thanks for your message!",
success : false,
failure : function() {}
})
});
That's the content of the snippet:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = "From: XXX <[email protected]>\r\n";
$headers .= "Reply-To: [email protected]\r\n";
$headers .= "Content-Type: text/plain; charset=utf-8";
$receiver = "[email protected]" ;
if (!empty($name) & !empty($email) && !empty($message)) {
$body = "Name: {$name}\n\nE-Mail-Adresse: {$email}\n\nNachricht: {$message}\n\n\n";
$send = mail($receiver, 'Nachricht über XXX', $body, $headers);
if ($send) {
echo 'true';
} else {
echo 'false';
}
}
?>
Originally the ajaxSubmitFile was a php file like "contact.php". So my best guess is that the "true" out of the php doesn't get through to where it's needed, due to the detour over the resource "ajax-form".
I appreciate any hints or tips!