Search code examples
marketo

Marketo - Background form submission through ajax


I am loading marketo form in background. The form is submitted in background on a button click. But, during submission the page refreshes.

Since the form is in background and is not visible to the user, refreshing page is not a nice user experience. I thought about submitting the same through Ajax, but I am not sure to which endpoint URL I need to POST the data, since URLs are not shown in Marketo control panel.

Is it possible to submit marketo form in background through Ajax so that page do not refreshes?

Any help is greatly appreciated.

Thanks


Solution

  • By default, the form will refresh when submitted. You can override this by including an onSuccess callback. The callback will be called when the form has been successfully submitted but before the lead is forwarded to the follow up page. This can be used to prevent the lead from being forwarded to the follow up page after successful submission.

    form.onSuccess(function(values, followUpUrl) {
        return false;
    });