简体   繁体   English

最终:AJAX / jQuery / PHP表单提交和成功打开的模式框

[英]Final: AJAX/jQuery/PHP Form submission and modal box open on success

Thanks to Samuel Liew and other great helpers, the issue has been fixed. 感谢Samuel Liew和其他出色的帮手,此问题已得到解决。

As putting everything here was a mess, and it was poorly explained in the overall solution, I dediced to make a explanatory in my own web site. 由于将所有内容乱七八糟,并且在整体解决方案中没有得到充分说明,因此我致力于在自己的网站中进行说明。

I leave the DEMO for you to see if that's what you're looking for, and I leave the TUTORIAL for you to learn how to do this. 我将DEMO留给您看,这就是您要寻找的东西,我将TUTORIAL留给您学习如何做。

TUTORIAL: http://santz.com.ar/blog/ajax-form-submit-open-modal-box/ 教程: http//santz.com.ar/blog/ajax-form-submit-open-modal-box/

DEMO: http://santz.com.ar/files/demos/ajax-form-submit-open-modal-box/ 演示: http : //santz.com.ar/files/demos/ajax-form-submit-open-modal-box/

Hope I helped you! 希望我能帮到您! Thanks to all the ones that helped me! 感谢所有帮助我的人!


@Samuel Liew, and other great helpers. @Samuel Liew和其他伟大的助手。 THE ISSUE HAS BEEN FIXED. 该问题已解决。 I'll leave corected code for future guys that need this. 我将把正确的代码留给以后需要的人使用。

The case: http://santz.net/index.contacto.html (no longer available) 案例: http //santz.net/index.contacto.html (不再可用)

THIS WAS THE PROBLEM: 这是一个问题:

Target: The "website" must open a dialog/modal box/modal window after successful form submission. 目标:成功提交表单后,“网站”必须打开一个对话框/模式框/模式窗口。

Issue: The form submits successfully but the dialog/modal box/modal window doesn't open (rarely, it does open if you make another click...) 问题:表单提交成功,但对话框/模式框/模式窗口没有打开(很少,如果再次单击,它确实会打开...)

[Try it, that's why I gave you the link. [尝试一下,这就是我给您链接的原因。 There's no problem, the site is mine and I recieve the messages] 没问题,该网站是我的,我收到了邮件]

I hope you can help me... the idea is quite simple! 希望您能帮我...这个想法很简单! When the user submits the form, a dialog popsup instantly! 用户提交表单后,会立即弹出一个对话框!

THANKS A LOT! 非常感谢!

In this case, move the dialog function outside of the submit function: 在这种情况下,请将对话框功能移到提交功能之外:

$(function() {
    $('#popup-wrapper').modalPopLite({
        openButton: '#clicker',
        closeButton: '#close-btn'
    });
    $('#contact-form').submit(function() {
        $.ajax({
            type: "POST",
            url: $(this).attr('action'),
            data: $(this).serialize(),
            success: function() {
                $('#contact-form')[0].reset();
            }
        });
        return false;
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM