Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created December 2, 2015 22:25
Show Gist options
  • Save samueleresca/4df3acad04b5f87b0b42 to your computer and use it in GitHub Desktop.
Save samueleresca/4df3acad04b5f87b0b42 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>JSON - JSONP tests</title>
<!--Include jquery-->
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(function(){
//DEF response
var data = {};
data.title = "title";
data.message = "message";
//Handler on JSON anchor click
$('#select_link_JSON').click(function(e){
e.preventDefault();
//LOG
console.log('select_link_JSON clicked');
//JSON request
$.ajax({
data: JSON.stringify(data),
contentType: 'application/json',
url: 'http://localhost:3000/endpointJSON',
success: function(data) {
console.log('success');
console.log(JSON.stringify(data));
}
});
});
});
</script>
</head>
<body>
<div id="select_div_JSON"><a href="#" id="select_link_JSON">Test JSON</a></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment