The ref feature

Peter Karman edited this page Sep 7, 2018 · 5 revisions

The ref feature

You can use the KSVotes ref feature to send a reference code to initiate a registration session.

There are two ways to use ref.

GET request

If you enter https://www.ksvotes.org/ref?ref=your-org into your browser, the your-org ref code will be saved and used for every registration until your browser is restarted.

POST request

You can host a form on your own server, in order to capture voter information before redirecting to KSVotes.org.

This example HTML snippet shows how you can create a form, gather input, and then redirect to KSVotes.

<html>
<body>
 <div>
  <h1>KSVotes.org test</h1>
   <form id="ksvotes" method="POST" action="https://www.ksvotes.org/ref?ref=wiki-example">
    <div>
     <input name="name_first" value="" > First Name
    </div>
    <div>
     <input name="name_last" value="" > Last Name
    </div>
    <div>
     <input name="dob" value="" placeholder="mm/dd/yyyy"> DOB
    </div>
    <div>
     <input name="email" value="" placeholder="you@example.com" type="email"> Email
    </div>
    <div>
     <input name="phone" value="" placeholder="555-555-5555" type="tel"> Phone
    </div>

    <button>Submit</button>
 </div>

 <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
 <script>
   let $form = $('#ksvotes');
   $form.on('submit', function(ev, opts) {
     let options = opts || {};
     if (!options.payload_saved) {
       let $payload = $form.serialize();

       // pause our ksvotes form submit to save the data locally
       ev.preventDefault();

       // send the data to our own server
       $.ajax({
         method: 'POST', // IMPORTANT to keep PII out of your server logs
         data: $payload,
         complete: function(data) {
           // pick up where we left off and continue to ksvotes
           $(ev.currentTarget).trigger('submit', { 'payload_saved': true });
         }
       });
     } else {
       alert("Sending data to KSVotes!");
     }
   });
 </script>
</body>
</html>
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.