Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
demo of jquery get enhanced
var sillyWords = ["incredible", "awesome", "amazing", "fantastic"];
$('button#start').click(function() {
var button = $(this).attr('disabled', 'disabled');
$.get('endpoint/data.html #target', function(data) {
// do something amazing with the data
if (data) {
// fetch word
var word = sillyWords[Math.floor(Math.random() * sillyWords.length)];
// replace
var output = data.replace(/cool/ig, word);
// write to DOM
$('.target').html(output);
}
button.removeAttr('disabled');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.