Created
April 21, 2016 17:56
-
-
Save jkarnowski/967635ed14af4b0d7151a23412f902a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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