Created
March 9, 2011 11:44
-
-
Save benbarnett/862066 to your computer and use it in GitHub Desktop.
demo of jquery get enhanced
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
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