Javascript Magento Create Account Preference Error

时间:2015-06-26 09:54:20

标签: javascript php forms magento

I am trying to create a second action on the Create New User Account form on Magento 1.9CE. We need an additional action to build an HTTP string and send to a URL as configured. So far we have built a script to pick up the fields, but this javascript isn't processing because the VarienForm is attached the event handler on document load. Could anybody shed some light on this code we have as to why its not processing?

<script type="text/javascript">
$(document).ready(function() { 
    window.setTimeout(function() {
        $('#form-validate').on('submit', function( e )
        {
            var elements = this.elements;
            e.preventDefault();
            e.stopPropagation();

            var subscribed = elements.is_subscribed.checked ? "y" : '';
            var bglink = "http://suite9.emarsys.net/u/register_bg.php?owner_id=428212131&f=1481&key_id=3&optin=" + subscribed + "&inp_1=" + elements.firstname.value + "&inp_2=" + elements.lastname.value + "&inp_3=" + elements.email_address.value + "&inp_4=" + elements.year.value + "-" + elements.month.value + "-" + elements.day.value;

            var img = $('<img width="1" height="1" src="'+bglink+'">')
                .on('load error', $.proxy(function()
                {
                    HTMLFormElement.prototype.submit.apply(this);
                }, this))
                .appendTo(this);

            return false;
        });
    }, 2000);
}); 
</script>

1 个答案:

答案 0 :(得分:0)

如果你在你的网站上使用jquery可能是jquery和原型是冲突的,要解决它: - 首先你要添加jQuery.noConflict();到你的网站 - 第二个替换$ equal jQuery 例如:jQuery(document).ready(function(){})