Set up an AJAX submission for Salesforce Pardot forms instead of POST with iframe, and handle the result.
“Pardot Form AJAX Handler”, or “PFAH” in short,
will help to you setup an AJAX
submission
for Salesforce Pardot forms,
which were designed to submit with POST
in iframe
. With JSONP
,
we can even handle the result from Pardot’s redirect.
dist
folder to your server.//sample.com/pfah/
.<script src="//sample.com/pfah/pardot-form.js"></script>
//sample.com/pfah/pardot-form-callback-done.js
.//sample.com/pfah/pardot-form-callback-error.js
.Once you’ve wrapped .pfah-form
with .pfah-wrapper
,
you are good to go!.pfah-done
or .pfah-error
are shown when the result comes back from Pardot.
<div class="pfah-wrapper">
<form action="https://go.pardot.com/l/285052/2018-02-23/22nrnw" class="pfah-form">
<input type="email" class="pfah-input" name="email" required />
<input type="text" class="pfah-input" name="name" />
<button type="submit" class="pfah-input">Submit</button>
</form>
<aside class="pfah-done">
<div class="pfah-done-text">Thank you for your time!</div>
</aside>
<aside class="pfah-error">
<span class="pfah-error-text">Something wrong, please try again!</span>
</aside>
</div>
For more examples, please check demo
folder.
demo-basic.html
: Basic inpage and popup forms.demo-css.html
: Form with preloaded style.demo-event.html
: Form with event controls.demo-popup.html
: Manually trigger popup when blocked.[type="submit"]
button/input to submit your form.Extra configuration can pass to PFAH by add data
properties to .pfah-wrapper
.
data-state="done"
: PFAH will save “done/error” state into localStorage
with .pfah-wrapper
ID..pfah-done
or/and .pfah-error
next time when user visit the page.data-source="source"
: PFAH will add a [type="hidden"]
to pass current url to Pardot for tracking purpose.source
or your customized field to Pardot form to make it work.data-style="no"
: Use this option to complete disable the style of PFAH by not load css file at all.data-error="keep"
: Use this option to reserve the space for error message.data-remember="no"
: Use this option to disable input auto-complete function.localStorage
with same name.data-recaptcha="your_site_key"
: Use this option to add reCAPTCHA v2 checkbox to your form..pfah-wrapper
in .pfah-popup
..pfah-popup
with class or ID#my-form
.pfah-
data-toggle="pfah-popup"
data-target
to link the element with PFAHclick
event is blocked..pfah-close
will close current popup..pfah-close-delay
on <a>
if you decide to download then close popup.
<button data-toggle="pfah-popup" data-target="#my-form"></button>
...
<div class="pfah-popup" id="my-form">
<div class="pfah-wrapper">
<i class="pfah-close-icon pfah-close pfah-icon"></i>
...
</div>
</div>
PFAH has a customized checkbox style.
With .pfah-check-required
, PFAH will show “error” state if those checkboxes were not selected on submit.
<label class="pfah-check-item">
<input class="pfah-check-input pfah-check-required" type="checkbox" checked>
<span class="pfah-check-icon pfah-icon"></span>
<span class="pfah-check-label">Agree terms.</span>
</label>
pfah.init()
: PFAH will initialize automatically when DOM
is ready. However you can manually perform it if forms are loaded into page asynchronously.pfah.callback({ result: state })
: PFAH will callback from pardot-form-callback-done.js
and pardot-form-callback-error.js
automatically after a form is submitted. However you can manually if you want to simulate the form result.state
can be “done“ or “error“.pfah.form.id
needs to be indicated before your call.pfah.popup(target)
: If your click
event is blocked on element, you can try to call it manually.PFAH will log to console
when some of following events happen to .pfah-wrapper
:
pfah.notpardot
: A form action
was not a proper Pardot iframe embed link.pfah.vendor
: A vendor of PFAH is loading to page, with its name.pfah.ready
: A form is ready to use, with .pfah-wrapper
id.pfah.submit
: A form was submitted to Pardot, with .pfah-wrapper
id.pfah.callback
: Received result from Pardot, with .pfah-wrapper
id and “done/error“ result.pfah.popup
: A popup is triggered by user, with .pfah-wrapper
id and “open/close“ state.pfah.callpopup
: PFAH is asked to show popup..pfah-row-with-col
: The inputs in PFAH can be either take full width or only half of the row.
<div class="pfah-row">
<div class="pfah-col">
...
</div>
</div>
...
<div class="pfah-row pfah-row-with-col">
<div class="pfah-col">
...
</div>
<div class="pfah-col">
...
</div>
</div>
.pfah-center
: Align text to center.
<div class="pfah-title pfah-center">My Form</div>
.pfah-hidden
: Hide something from user.
<div class="pfah-hidden">Secret</div>
PFAH allow you to override default style by adding your own css
file.
Different forms can use their own themes even they are on the same page.
pardot-form-mytheme.css
to same folder you put PFAH.//sample.com/pfah/pardot-form-mytheme.css
data-theme="mytheme"
to .pfah-wrapper
.```text
190911
180903
180709
180629
180626
180620
180619
180616
180613
180608
180607