2015-08-24 90 views
0

這裏是我的JSFIDDLEMailchimp註冊表單是行不通的訂閱按鈕

當我運行這段代碼,當我點擊訂閱按鈕,什麼也沒發生。

我試圖改變放置代碼的位置,但仍然找不到錯誤。

<div class='popup'> 
<div class='cnt223'> 
<img src='http://s14.postimg.org/w3j8ay2bh/1440412582_cross_24.png' 
alt='quit' class='x' id='x' /> 
<p> 
<div id="mc_embed_signup"> 
<form action"//wafytech.us11.list-manage.com/subscribe 
/post?u=4cc1d72c9827dd3ef80675e4c&amp;id=4d5daa8c14" 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-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-FNAME">First Name </label> 
    <input type="text" value="" name="FNAME" class="" id="mce-FNAME"> 
</div> 
<div class="mc-field-group"> 
    <label for="mce-LNAME">Last Name </label> 
    <input type="text" value="" name="LNAME" class="" id="mce-LNAME"> 
</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;"><input type="text" 
name="b_4cc1d72c9827dd3ef80675e4c_4d5daa8c14" tabindex="-1" value=""></div> 
    <div class="clear"> 
    <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded- 
subscribe" class="button"></div> 
    </div> 
</form> 
</div> 
<br/> 
</p> 
</div> 
</div> 
+0

您在外部腳本上有錯誤。將它移到文檔末尾 –

回答

1

錯誤是因爲您在文檔加載完成之前加載了http://s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js

線196,您有以下:

getAjaxSubmitUrl: function() { 
     var url = $("form#mc-embedded-subscribe-form").attr("action"); 
     url = url.replace("/post?u=", "/post-json?u="); 
     url += "&c=?"; 
     return url; 
    }, 

它給我的錯誤上url = url.replace("/post?u=", "/post-json?u=");因爲$("form#mc-embedded-subscribe-form")無法獲取正確的元素,由於沒有被加載的文件。因此,.attr("action")將返回undefined。嘗試在整個代碼中添加一個.ready事件偵聽器。

另外,正確的方法是$("#mc-embedded-subscribe-form")


要上添加,你也有這樣的你的HTML:

<form action"[...]"> 

你忘了=action和值之間。它應該是這樣的:

<form action="[...]"> 

注意的=那裏!

+0

抱歉,我無法理解..請簡要介紹一下嗎?謝謝... – pcs

+0

@saina你不瞭解什麼? –

+0

我可以在哪裏更改我的代碼?謝謝 – pcs