Skip to content

Instantly share code, notes, and snippets.

@jkarnowski
Created April 21, 2016 17:56
Show Gist options
  • Save jkarnowski/967635ed14af4b0d7151a23412f902a0 to your computer and use it in GitHub Desktop.
Save jkarnowski/967635ed14af4b0d7151a23412f902a0 to your computer and use it in GitHub Desktop.
// so I can call cheerListener() on doc ready
// only takes care of listening for the data
function cheerListener(){
$('#cheer_caller').on('submit', function(event){
event.preventDefault();
var formData = $(this).serialize();
submitForm(formData)
})
}
// takes care of the AJAX call
var submitForm = function(formData){
$.ajax({
url: '/cheers',
type: 'POST',
data: formData
})
.done(function(response){
$(".sign-text").text(response)
$('input:text').val("");
$('#cheer-input').focus();
})
.fail(function(response){
console.log("FAILING!")
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment