Created
December 2, 2015 22:25
-
-
Save samueleresca/4df3acad04b5f87b0b42 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<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