Skip to content
Set up an AJAX submission for Salesforce Pardot forms instead of POST with iframe, and handle the result.
Branch: master
Clone or download
Latest commit 558649d Jan 22, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo update readme Jul 9, 2018
LICENSE update path detect Sep 3, 2018
_config.yml Set theme jekyll-theme-cayman Aug 18, 2018

Pardot Form AJAX Handler

"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.


  1. Extract and upload all the files in dist folder to your server.
    • e.g., //


  1. Add main script after jQuery is introduced.
    • e.g., <script src="//"></script>
  2. Go to Pardot and edit success/error location of the form.
    • set "Success Location" as //
    • set "Error Location" as //

Basic Usage

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="" 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>
  <aside class="pfah-done">
    <div class="pfah-done-text">Thank you for your time!</div>
  <aside class="pfah-error">
    <span class="pfah-error-text">Something wrong, please try again!</span>


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.


  • Make sure that you have [type="submit"] button/input to submit your form.
  • Multiple forms are supported, while same forms share same states.

Advanced Usage


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.
    • This attribute can be either "done", "error" or "all".
    • With form states, PFAH will show .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.
    • This attribute can be customized according to your choice, but we suggest to use "source" or "referrer".
    • You have to add source or your customized field to Pardot form to make it work.
    • You have to make sure you haven't use the same name somewhere else in form.
  • data-style="no": Use this option to complete disable the style of PFAH by not load css file at all.
    • You can use this option if you decide to import css file by yourself.
    • This option will disable theme as well.
  • data-error="keep": Use this option to reserve the space for error message.
    • By default, PFAH will slide down the error message.
  • data-remember="no": Use this option to disable input auto-complete function.
    • By default, PFAH will keep value you input in localStorage with same name.


  1. Wrap your .pfah-wrapper in .pfah-popup.
  2. Name your .pfah-popup with class or ID
    • e.g., #my-form.
    • Please DO NOT name it with prefix of pfah-
  3. Toggle popup with any element with data-toggle="pfah-popup"
    • Use data-target to link the element with PFAH
    • You can manually toggle popup if click event is blocked.
    • Clicking on any elements with .pfah-close will close current popup.
    • Use .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>


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>


  • pfah.init(): PFAH will initialize automatically when DOM is ready. However you can manually perform it if forms are loaded into page asynchronously.
    • Load default form style (and extra theme).
    • Check form action url.
    • Generate ID.
    • Show stored state.
    • Load vendor js if there is a form shown in popup.
  • 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.
    • Trigger callback events.
    • state can be "done" or "error".
    • 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.
    • Trigger call popup event.


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 class="pfah-row pfah-row-with-col">
  <div class="pfah-col">
  <div class="pfah-col">
  • .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.

  1. upload pardot-form-mytheme.css to same folder you put PFAH.
    • e.g., //
  2. add data-theme="mytheme" to .pfah-wrapper.
    • Make sure your theme name is in lower case.




Change logs


  • path detect fallback


  • samples: css/popup
  • events: ready/popup


  • debouce input
  • more samples

build 180626

  • allow same forms
  • allow remember input


  • allow close popup


  • allow required checkbox
  • allow text center


  • add icons
  • add demo
  • allow popup
  • allow half row column


  • update basic style
  • allow keep error message


  • allow source track
  • allow style disable
  • unify init function


  • initial release
You can’t perform that action at this time.