AJAX Submission

Easily extend your Slapforms to use AJAX instead of the default HTML form.

What is an AJAX submission

AJAX is a technique to access web servers using Javascript. You can use it to submit Slapform via Javascript instead of the default HTML form, and it's super easy to set up.

AJAX is a part of jQuery, but if you don't want to use jQuery you can also use our Slapform NPM module that does the same thing and it's a much smaller library (it works in browser and node environments seamlessly).

AJAX Example

Below is a "kitchen-sink" example utilizing all of the available Name Triggers. Copy and paste and customize to your needs!


      <script type="text/javascript">
        $( document ).ready(function() {
            url: 'https://api.slapform.com/[email protected]',
            dataType: 'json',
            method: 'POST',
            data: {
              name: 'Jon Snow',
              message: 'Hello World! This is my first Slapform submission.',
              /* Name triggers */
              slap_subject: 'My Favorite Message',
              slap_replyto: '[email protected]'
              slap_debug: false,
              slap_webhook: 'https://yourwebsite.com/webhook',
              slap_honey: ''
              /* These Slapform Name Triggers exist but aren't applicable to AJAX submissions */
              // slap_redirect: 'https://yourwebsite.com',
              // slap_captcha: false,

            success: function (response) {
              console.log('Got data: ', response);
              if (response.meta.status == 'success') {
                console.log('Submission was successful!');
                // window.location.href = 'https://google.com' // Uncomment this line if you want to redirect the user upon a successful submission
              } else if (response.meta.status == 'fail') {
                console.log('Submission failed with these errors: ', response.meta.errors);

Extending Slapform

Slapform can be easily extended to do some pretty advanced stuff:

  1. Include advanced name triggers to customize the email, push webhooks, and more
  2. Take Slapform to the server-side with our NPM module. Learn how to submit using the NPM module
× You are using an outdated browser that our site DOES NOT support. Please click here to update your browser.