-1

我正在使用 GetResponse 网络表单,并且我需要在成功提交表单后弹出一个花式框窗口?

这是 GetResponse 网络表单的代码段

<form id="gold_ira_form" accept-charset="utf-8" action="https://app.getresponse.com/add_contact_webform.html?u=bPSV"
                            method="post">

//form code goes here....

<input type="submit" id="submit-btn" value="submit"></input>
</form>

这是我的 JQuery 代码:

   <script>
            $(function() {
                $('#gold_ira_form').submit(function() {
                    // will be replaced with fancy box code 
                    alert('Sent! show fancybox');

                });
            });
        </script>

上述代码在表单提交成功后不执行警报。

成功提交表单后,是否有任何替代方法可以执行 jquery 功能?

4

2 回答 2

1

通常当您提交表单时,它会自动刷新页面(或者它会重定向到“action”属性值页面)。为了解决这个问题,我建议尝试通过 ajax 提交表单:

$('#gold_ira_form').on('submit', function(e) {
    e.preventDefault();
    //Ajax code goes here, on ajax complete call fancybox
});
于 2015-02-05T08:03:56.717 回答
0

试试下面的代码

   <script>
        $('document').ready(function() {
            $('#gold_ira_form').submit(function() {

                alert('Sent! show fancybox');
                return false;

            });
        });
    </script>
于 2015-02-05T08:05:06.940 回答