Wednesday, 11 September 2013

jquery not working in mailchimp evil popup after user clicks submit

jquery not working in mailchimp evil popup after user clicks submit

I added an evil popup newsletter signup to my shopify site last night, and
everything works fine except...
upon clicking submit, the jquery used to display a success message and
close the popup doesn't run. The popup form just stays where it is and
does nothing even though the signup was successful.
You can check it here: http://www.finegra.in/
This is the function for displaying success:
Here is the HTML form:
<div id="mc_embed_signup">
<form
action="http://finegra.us5.list-manage.com/subscribe/post?u=9ea828a0b2b999cf86b196bd5&amp;id=d6cd179498"
method="post" id="mc-embedded-subscribe-form"
name="mc-embedded-subscribe-form" class="validate" target="_blank"
novalidate>
<h2 id="firstH2">Want to know when our new products are available?</h2>
<h2 id="secondH2">Sign up here and we'll keep you in the loop.</h2>
<div class="mc-field-group">
<!-- <label class="" for="mce-EMAIL">Email Address </label> -->
<input type="email" value="" placeholder="Email Address" 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="required" id="mce-FNAME">
</div>
<div class="mc-field-group" id="last-field-group">
<label for="mce-LNAME">Last Name </label>
<input type="text" value="" name="LNAME" class="required" id="mce-LNAME">
</div> -->
<a href="#" id="mc_embed_close" class="mc_embed_close">Close</a> <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> <div id="submitDiv"><input type="submit" value="Subscribe"
name="subscribe" id="mc-embedded-subscribe" class="button
abutton"></div>
</form>
</div>
Here are the jQuery functions for success and closing the popup:
Close:
function mcEvilPopupClose(){
$('#mc_embed_signup').hide();
var now = new Date();
var expires_date = new Date( now.getTime() + 31536000000 );
document.cookie = 'MCEvilPopupClosed=yes;expires=' +
expires_date.toGMTString()+';path=/';
}
success:
function mce_success_cb(resp){
$('#mce-success-response').hide();
$('#mce-error-response').hide();
if (resp.result=="success"){
$('#mce-'+resp.result+'-response').show();
$('#mce-'+resp.result+'-response').html(resp.msg);
$('#mc-embedded-subscribe-form').each(function(){
this.reset();
});
} else {
var index = -1;
var msg;
try {
var parts = resp.msg.split(' - ',2);
if (parts[1]==undefined){
msg = resp.msg;
} else {
i = parseInt(parts[0]);
if (i.toString() == parts[0]){
index = parts[0];
msg = parts[1];
} else {
index = -1;
msg = resp.msg;
}
}
} catch(e){
index = -1;
msg = resp.msg;
}
try{
if (index== -1){
$('#mce-'+resp.result+'-response').show();
$('#mce-'+resp.result+'-response').html(msg);
} else {
err_id = 'mce_tmp_error_msg';
html = '<div id="'+err_id+'" style="'+err_style+'">
'+msg+'</div>';
var input_id = '#mc_embed_signup';
var f = $(input_id);
if (ftypes[index]=='address'){
input_id = '#mce-'+fnames[index]+'-addr1';
f = $(input_id).parent().parent().get(0);
} else if (ftypes[index]=='date'){
input_id = '#mce-'+fnames[index]+'-month';
f = $(input_id).parent().parent().get(0);
} else {
input_id = '#mce-'+fnames[index];
f = $().parent(input_id).get(0);
}
if (f){
$(f).append(html);
$(input_id).focus();
} else {
$('#mce-'+resp.result+'-response').show();
$('#mce-'+resp.result+'-response').html(msg);
}
}
} catch(e){
$('#mce-'+resp.result+'-response').show();
$('#mce-'+resp.result+'-response').html(msg);
}
}
}

No comments:

Post a Comment