Ajax Signup form failing in Webkit browsers.

Hi there,

I'm using the Ajax signup form but I'm having no luck getting it to work in Safari or Chrome. I guess it's a JavaScript issue but I don't really know, any help would be appreciated. Here is the script as it's different from the original one (see here) the php is the same:

$(function() {
    $(".interest-form button").click(function() {         
        // First, disable the form from submitting
        $('.interest-form').submit(function() { return false; });
        
        // Grab form action
        formAction = $(".interest-form").attr("action");
        
        // Hacking together id for email field
        // Replace the xxxxx below:
        // If your form action were http://mysiteaddress.createsend.com/t/r/s/abcde/, then you'd enter "abcde" below
        emailId = "duihky";
        emailId = emailId.replace("/", "");
        emailId = emailId + "-" + emailId;
        
        // Validate email address with regex
        if (!checkEmail(emailId)) {
            $('.error').slideDown("show", function() {
                $('.error').addClass('hasError');
            });
            return;
        } else {
            $('.hasError').hide();
        }
        
        // Serialize form values to be submitted with POST
        var str = $(".interest-form").serialize();
        
        // Add form action to end of serialized data
        final = str + "&action=" + formAction;
        
        // show spinner
        $("#loading").fadeIn("slow");
        
        // Submit the form via ajax
        $.ajax({
            type: "POST",
            url: "proxy.php",
            data: final,
            success: function(data){
                $("#theForm").hide(); // If successfully submitted hides the form
                $("#confirmation").slideDown("slow");  // Shows "Thanks for subscribing" div
                $("#loading").fadeOut("slow");
                //$("#duihky-duihky").val('Your email address');
            }
        });
    });
});
function checkEmail(email) {    
    var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var emailVal = $("#" + email).val();
    return pattern.test(emailVal);
}

Many thanks in advance.

Jamie

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098