Skip to content

Instantly share code, notes, and snippets.

@dynax60
Created September 3, 2010 08:10
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 dynax60/563588 to your computer and use it in GitHub Desktop.
Save dynax60/563588 to your computer and use it in GitHub Desktop.
An example of JSONP usage (cross-domain) with JQuery.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<SCRIPT>
$(function() {
$('#clickme').click(function() {
$.getJSON('http://domain.tld/test/?foo=bar&callback=?',
function(jsonp) {
$('#jsonp-example').html(jsonp.result);
});
});
});
</SCRIPT>
<div id="jsonp-example"><a id="clickme" href="javascript:void()">Click me</a></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment