I'm using Gravity Forms on a WP site. My forms POST via ajax to Pardot using Pardot form handlers. I am running into an issue where Pardot processes the form 6x, with no other errors. Research indicates that this is because Pardot does not support CORS or JSONP, and thus gets stuck in a loop when using ajax to submit. It's processing the submission but never "finishing" when the form handler's Success URL is set as referring URL. It tries 6x before giving up, processing the submitted data and sending new prospect notification emails each time.
Pardot help docs suggest the following solution:
It is possible to simulate a JSONP response by setting the Success and Error URLs for the form handler to be JavaScript URLs that execute Success and Error callbacks, respectively.
I'm not totally sure what this means or how to approach it. I've done some stackoverflowing and googling, but I can't seem to wrap my head around how to do it. Can someone help clarify this concept or point me in the right direction?
Thanks!
What Pardot is suggesting is to create 2 static URLs on your own server that return a simple JSON response.
So for example:
mysite.com/pardot-success
Returns: {"result":"success"}
mysite.com/pardot-error
Returns: {"result":"error"}
You'll then use those two URLs as your success and error redirect URLs for your Pardot form handler settings.
An AJAX request can then be made to your Pardot form handler using JSONP, which will wrap and return the JSON response from one of those URLs (depending on the result).
Your AJAX response data would include your JSON result (success or error).