Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
     <div class="col-md-6 offset-md-3 mt-5">
        <a target="_blank" href="https://getform.io?ref=codepenHTMLAjax">
          <img src='https://i.imgur.com/Z2Nyxsm.png'>
        </a>
        <br>
        <a target="_blank" href="https://getform.io?ref=codepenHTMLAjax" class="mt-3 d-flex">Get your free endpoint now</a>
        <h1>Getform.io Contact Form HTML Ajax (Jquery) Example</h1>

        <form accept-charset="UTF-8" action="https://getform.io/f/d709b72b-d30b-4316-9cc1-4d1d33778a8b" method="POST" target="_blank" id="ajaxForm">
          
          <div class="form-group">
            <label for="exampleInputEmail1" required="required">Email address</label>
            <input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
          </div>
          <div class="form-group">
            <label for="exampleInputName">Name</label>
            <input type="text" name="name" class="form-control" id="exampleInputName" placeholder="Enter your name" required="required">
          </div>
          <div class="form-group">
            <label for="exampleFormControlSelect1">Favourite Platform</label>
            <select class="form-control" id="exampleFormControlSelect1" name="platform" required="required">
              <option>Github</option>
              <option>Gitlab</option>
              <option>Bitbucket</option>
            </select>
          </div>
          <div class="success">We received your submission, thank you!</div> 
          <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>

              
            
!

CSS

              
                h1 {
  font-size: 20px;
  margin-top: 24px;
  margin-bottom: 24px;
}

img {
height: 40px;}

.success {
  display: none;
  background: #E1F8ED;
  padding: 20px;
  margin-top: 16px;
  margin-bottom: 16px;
  &.is-active {
    display: block;
  }
}
              
            
!

JS

              
                $("#ajaxForm").submit(function(e){
  e.preventDefault();
  var action = $(this).attr("action");
  var data = {};
  $(this).serializeArray().map(function(x){data[x.name] = x.value;}); 
  $.ajax({
    type: "POST",
    url: action,
    data: JSON.stringify(data),
    contentType: "application/json",
    headers: {
      "Accept": "application/json"
    }
  }).done(function() {
     $('.success').addClass('is-active');
  }).fail(function() {
     alert('An error occurred please try again later.')
  });
});
              
            
!
999px

Console