Created
March 10, 2012 02:31
-
-
Save luk-/2009762 to your computer and use it in GitHub Desktop.
for Todd
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
<!DOCTYPE html> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
var get_servlet_call = function (url) { | |
$.get (url, function (data) { | |
// this callback function is called on successful return of the url passed to $.get | |
// function (data) is the callback here — in javascript it's considered an anonymous function. | |
alert(data); | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
<button id="button_id" class="button_class">click me</button> | |
<script type="text/javascript"> | |
// i put this js here at the end of the body so the jquery event handler loads after the dom element upon which it acts | |
$("#button_id").click (function () { | |
get_servlet_call("text.html"); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment