0

I have a freeform pro form that is using a piece of javascript to provide a progress indicator once a form is submitted. Idea is seen here: http://tympanus.net/Development/ProgressButtonStyles/

However, with this script enabled, the form will not submit. When I comment out the js, the form submits fine. I cannot figure out what I need to edit in the script to play nice with Freeform. Code is as follows:

function initProgressBtn(){
    jQuery('.form').each(function() {
        var form = jQuery(this);
        var sendBtn = form.find('.progress-button');
        var ajaxBusy = false;

        new ProgressButton( sendBtn.get(0), {
            callback : function( instance ) {
                var progress = 0,
                interval = setInterval( function() {
                    progress = Math.min( progress + Math.random() * 0.1, 1 );
                    instance._setProgress( progress );

                    if( progress === 1 ) {
                        instance._stop(1);
                        clearInterval( interval );
                    }
                }, 200 );
                form.trigger('startProgress');
            }
        });

        function onSendForm(e) {
            e.preventDefault();
            if(!ajaxBusy) {
                ajaxBusy = true;

                jQuery.ajax({
                    url: form.attr('action'),
                    type: form.attr('method'),
                    data: form.serialize(),
                    dataType: 'text',
                    success: function() {

                    }
                });
            }
        }

        form.on('submit startProgress', onSendForm);
    });
}

Any help would be greatly appreciated - thanks!

1 Answer 1

1

I was able to fix this by adding the redirect url directly in the javascript:

success: function() {
window.location.href = "redirected-page.html";
}
1
  • Glad you got this sorted and reported back; you should accept your own answer so this question will not appear as "unanswered".
    – AllInOne
    Oct 5, 2015 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.