如何将验证引擎js与jQuery AJAX和PHP电子邮件提交集成?

发布于 2024-12-11 23:43:44 字数 1576 浏览 0 评论 0原文

我正在使用 https://github.com/posabsolute/jQuery-Validation-Engine

验证有效,但 AJAX 不起作用...... 问题是它对我来说很多次都不起作用,我尝试这样做但失败了30多次,我不知道为什么,他的AJAX提交php示例对我没有用......

有我的脚本来验证表单:

    $("#formID").validationEngine({promptPosition : "centerRight", scroll: false, ajaxFormValidation: true});

有一个我想与验证引擎集成的 jQuery AJAX 脚本:

$.ajax({
    type: "POST",
    url: "send.php",
    data: sendData,
    beforeSend: function () {
        $("#ajax").show();
    },
    success: function () {

        $('#listo').html("<p>Thank you!</p>")
            .hide()
            .fadeIn(1000, function () {

        });
    }
});                       

还有另一个我的 PHP 脚本来发送数据表单:

function send_email() {
$message = "\nNombre: " . $_POST['nombre'] .
    "\nEmail: " . $_POST['email'] .
    "\nMensaje: " . $_POST['message'] .
    "\nTélefono: " . $_POST['tel'];

$message .= "\n\nBrowser Info: " . $_SERVER["HTTP_USER_AGENT"] .
    "\nIP: " . $_SERVER["REMOTE_ADDR"] .
    "\n\nDate: " . date("Y-m-d h:i:s");

$siteEmail = '[email protected]';
$emailTitle = 'Contact from your website';
$thankYouMessage = "succesful sent.";   

if(! mail($siteEmail, $emailTitle, $message, 'From: ' . $_POST['nombre'] . ' <' . $_POST['email'] . '>'))
    echo 'cannot send...';

}

任何人都可以帮助我吗?

I am using from https://github.com/posabsolute/jQuery-Validation-Engine

The validation worked, but AJAX didn't work...
The problem is that it didn't work to me many times, i tried to do it but it failed more than 30 times, i don't know why, his AJAX submit php example isn't useful to me...

There is my script to validate the form:

    $("#formID").validationEngine({promptPosition : "centerRight", scroll: false, ajaxFormValidation: true});

There is my jQuery AJAX script that i want to integrate with Validation Engine:

$.ajax({
    type: "POST",
    url: "send.php",
    data: sendData,
    beforeSend: function () {
        $("#ajax").show();
    },
    success: function () {

        $('#listo').html("<p>Thank you!</p>")
            .hide()
            .fadeIn(1000, function () {

        });
    }
});                       

And there another my PHP script to send data form:

function send_email() {
$message = "\nNombre: " . $_POST['nombre'] .
    "\nEmail: " . $_POST['email'] .
    "\nMensaje: " . $_POST['message'] .
    "\nTélefono: " . $_POST['tel'];

$message .= "\n\nBrowser Info: " . $_SERVER["HTTP_USER_AGENT"] .
    "\nIP: " . $_SERVER["REMOTE_ADDR"] .
    "\n\nDate: " . date("Y-m-d h:i:s");

$siteEmail = '[email protected]';
$emailTitle = 'Contact from your website';
$thankYouMessage = "succesful sent.";   

if(! mail($siteEmail, $emailTitle, $message, 'From: ' . $_POST['nombre'] . ' <' . $_POST['email'] . '>'))
    echo 'cannot send...';

}

Anyone can help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天涯离梦残月幽梦 2024-12-18 23:43:44

你能尝试一下这个吗:

jQuery(document).ready(function () {
    jQuery("#formID").validationEngine({
        promptPosition: "centerRight",
        scroll: false,
        ajaxFormValidation: true,
        ajaxFormValidationURL: "send.php",
        onBeforeAjaxFormValidation: function () {
            $("#ajax").show();
        },
        onAjaxFormComplete: function () {
            $('#listo').html("<p>Thank you!</p>")
                .hide()
                .fadeIn(1000);
        }
    });
});

Could you try this out:

jQuery(document).ready(function () {
    jQuery("#formID").validationEngine({
        promptPosition: "centerRight",
        scroll: false,
        ajaxFormValidation: true,
        ajaxFormValidationURL: "send.php",
        onBeforeAjaxFormValidation: function () {
            $("#ajax").show();
        },
        onAjaxFormComplete: function () {
            $('#listo').html("<p>Thank you!</p>")
                .hide()
                .fadeIn(1000);
        }
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文