Skip to content

Instantly share code, notes, and snippets.

@sarnobat
Last active August 30, 2017 22:50
Show Gist options
  • Save sarnobat/d95d966656201314d549615b3ef5991c to your computer and use it in GitHub Desktop.
Save sarnobat/d95d966656201314d549615b3ef5991c to your computer and use it in GitHub Desktop.
jQuery call REST service
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.getJSON("http://localhost:9099/helloworld/json?param1=" + encodeURIComponent(document.getElementById("urls").innerHTML),function(result){
$.each(result, function(i, field){
$("#items").append(i + " " + field + " ");
});
});
});
});
</script>
</head>
<body>
<textarea id="urls">http://www.yahoo.com</textarea>
<button>Stash this</button>
<div id="items"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment