How do I send the data to external API after a form is submitted on a landing page ?

SanfordWhiteman
Level 10 - Community Moderator

Re: How do I send the data to external API after a form is submitted on a landing page ?

OK. You have two ways to implement this:

  • event chain waiting for the CAS submit to complete and then firing the Marketo submit in the callback (you may or may not want to fire Marketo if CAS fails)
  • scatter-gather firing both requests and waiting for them both to complete before allowing the page to navigate away (page unload aborts all unfinished requests, so you must leave the page in place until all are complete); you won't be able to prevent either one from firing this way

I recommend the former.

Francis_Poirier
Level 1

Re: How do I send the data to external API after a form is submitted on a landing page ?

Hi Sandford,

 

How would you delay the form submission and wait for the Ajax call to success before actually submitting the form exactly ? 

 

Thanks !

SanfordWhiteman
Level 10 - Community Moderator

Re: How do I send the data to external API after a form is submitted on a landing page ?


How would you delay the form submission and wait for the Ajax call to success before actually submitting the form exactly ? 

 

Thanks !


Set form.submittable(false) in onValidate. 

 

Then when you get the callback from your Ajax request, set form.submittable(true) and then form.submit().