AnsweredAssumed Answered

Marketo Embedded Forms 2.0 onSuccess() not firing in rare case

Question asked by Griffin Knotts on Mar 26, 2019
Latest reply on Mar 30, 2019 by Sanford Whiteman

We are running into a rare case where onSuccess() never fires. Here is the setup.

 

We embed a Marketo form (using Forms 2.0) into a page on our company's website. Our site can be accessed over http and https. Our Marketo domain is go.my.company.com and our website is my.company.com. We've also set up our Marketo domain to work over https.

 

We load the forms2 script via <script src="//go.my.company.com/js/forms2/js/forms2.min.js"></script>

 

In certain cases users had a permanent redirect in their local browser cache; they would hit the site over http, the forms2 script would attempt to load over http, then the redirect would apply and it would actually load over https. Whenever this happened the onSuccess() handler would never fire. It seems very strange because the onSubmit() would still fire, and no visible js errors would occur. Once a user cleared their redirect cache the issue went away.

 

Does anyone know why or how this redirect would cause onSuccess() to not fire?

 

Below is some slimmed-down sample code for our scenario.

 

$(document).ready(function () {
    var marketoFormHelper = new MarketoFormHelper();
    marketoFormHelper.loadForm(1);
}

function MarketoFormHelper() {
    this.loadForm = function(marketoFormId) {
          MktoForms2.loadForm("[//go.my.company.com]", "[my munckin id]", marketoFormId, function (mktoForm) {
              mktoForm.submittable(false);
              var $form = $('#' + mktoForm.getFormElem()[0].id);
              registerSubmitHandler($form, mktoForm);
              mktoForm.onSuccess(function (values, followUpUrl) {
                    console.log("form submitted successful");
                    return false;
              });
          });
    }

    function registerSubmitHandler($form, mktoForm) {
            $form.submit(function (e) {
                e.preventDefault();
                if (mktoForm.validate()) {
                    mktoForm.submittable(true);
                    mktoForm.submit();
                }
          });
    }
}

Outcomes