$(document).on("swell:setup", function(){ var referredCustomersInput = $("#referred-customers-input"); var sendEmailsBtn = $("#referred-customers-send-btn"); $(sendEmailsBtn).click(function(){ // assuming you allowed comma separated email input var emails = referredCustomersInput.val().split(","); var onSuccess = function(){ $("#success").show(); } var onError = function(err){ $("#error").show(); } swellAPI.sendReferralEmails(emails,onSuccess, onError); }); });