Skip to content

Instantly share code, notes, and snippets.

@luk-
Created March 10, 2012 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luk-/2009762 to your computer and use it in GitHub Desktop.
Save luk-/2009762 to your computer and use it in GitHub Desktop.
for Todd
<!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