The limitations of integrating Pardot Forms into React or modern framework
Here's a post that hopefully saves someone a few hours of googling. I have a client who has a React-based Kiosk application and they want to use Pardot Forms to capture leads. This seems like a relatively straightforward, even reasonable ask and I assume, you dear reader thought so too. So you've probably tried something like this, assuming that you can post to a form like some jackass who expects a modern framework that assumes that this is feasible and you envision and/or wrote something like the following in beautiful ES6/ESnext syntax:
This seems like it should work but, of course, it does not. Instead, you'll be greeted with a wonderful CORS error but the Pardot forms do not have any CORS controls. There's little information, and the developer documentation is sparse but I was able to unearth from the salesforce docs the following:
Submissions Using Ajax
Pardot doesn't support submitting data to form handlers via Ajax requests. When attempting to submit data to a form handler using Ajax, you will likely see errors like:
XMLHttpRequest cannot load {www.site.com/FormHandlerURL}. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '{page from which form handler should be getting submitted on client's website}' is therefore not allowed access.
This is what's known as CORS (Cross-Origin Resource Sharing). Pardot doesn't currently support CORS or JSONP for form handlers. 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.
So the answer is that it doesn't support AJAX and the only way is to hack the form responses to trigger JS scrips. I managed to find a GitHub project where a user created a Pardot Form AJAX Handler which shows an example with callbacks. Oy.
Bonus: As total newbie to Pardot, I found these videos helpful for navigating the Pardot interface. They're out of date, the UI has changed, but the core features can mostly be found in the same places.