Mailchimp" mce-error-response"创建文本而不是新选项卡

时间:2017-09-25 12:29:09

标签: jquery html css ajax mailchimp

我使用的是基本的mailchimp表单,看起来像这样

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>

<!-- Begin MailChimp Signup Form -->
<div id="mc_embed_signup">
<form action="http://facebook.us16.list-manage.com/subscribe/post?u=81d63ae912846f990f5307c84&amp;id=b817e70a9e" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
    <h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
    <label for="mce-FNAME">First Name  <span class="asterisk">*</span>
</label>
    <input type="text" value="" name="FNAME" class="required" id="mce-FNAME">
</div>
<div class="mc-field-group">
    <label for="mce-LNAME">Last Name  <span class="asterisk">*</span>
</label>
    <input type="text" value="" name="LNAME" class="required" id="mce-LNAME">
</div>
<div class="mc-field-group">
    <label for="mce-EMAIL">Email Address  <span class="asterisk">*</span>
</label>
    <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
    <label for="mce-JOB">Job Title  <span class="asterisk">*</span>
</label>
    <input type="text" value="" name="JOB" class="required" id="mce-JOB">
</div>
<div class="mc-field-group">
    <label for="mce-INDUSTRY">Industry  <span class="asterisk">*</span>
</label>
    <input type="text" value="" name="INDUSTRY" class="required" id="mce-INDUSTRY">
</div>
    <div id="mce-responses" class="clear">
        <div class="response" id="mce-error-response" style="display:none"></div>
        <div class="response" id="mce-success-response" style="display:none"></div>
    </div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_81d63ae912846f990f5307c84_b817e70a9e" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
    </div>
</form>
</div>
<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';fnames[0]='EMAIL';ftypes[0]='email';fnames[3]='JOB';ftypes[3]='text';fnames[4]='INDUSTRY';ftypes[4]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
<!--End mc_embed_signup-->

</body>
</html>

它与mailchimp一样基本...当我在浏览器中本地测试时,它的行为符合预期,并创建一个如下所示的新选项卡:enter image description here

但是,当在服务器上放置完全相同的代码时,相反,此新标签将呈现为一行文本,如下所示enter image description here

之前有没有人注意到这种行为?检查页面时仍然存在的错误是

Failed to load resource: net::ERR_FILE_NOT_FOUND

关于&#34; mce-error-response&#34;

任何见解都将受到赞赏。谢谢!

1 个答案:

答案 0 :(得分:1)

在本地测试代码时打开的选项卡实际上是 fallback 行为。该表单旨在直接在页面上显示验证错误,就像在服务器上测试时一样,但由于Failed to load resource错误而无法在本地执行此操作。这是这一行的结果:

<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script><script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';fnames[0]='EMAIL';ftypes[0]='email';fnames[3]='JOB';ftypes[3]='text';fnames[4]='INDUSTRY';ftypes[4]='text';}(jQuery));var $mcj = jQuery.noConflict(true);</script>

请注意,src属性并未包含类似&#39; http:&#39;或者&#39; https:&#39;。如果没有协议,则使用protocol of the current page。因此,本地文件包含&#39; file:///&#39;协议将尝试找到不存在的file:///s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js

该验证脚本包含使用AJAX提交表单的代码,因为the script的评论显示:

/**
 *  Grab the list subscribe url from the form action and make it work for an ajax post.
 */

因此,由于本地文件无法找到该脚本,因此它会回退到将表单提交到action属性中指定的URL的默认行为,并在新选项卡中打开,如target属性。