Skip to content

Instantly share code, notes, and snippets.

@sebm
Created March 29, 2012 07:28
Show Gist options
  • Save sebm/2234535 to your computer and use it in GitHub Desktop.
Save sebm/2234535 to your computer and use it in GitHub Desktop.
How to get JSONP working cross domain
<!DOCTYPE html>
<html>
<head>
<title>JSONP test</title>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
</head>
<body>
<script>
var named_callback = function() {
console.log('whoo it worked')
console.log(arguments)
};
$(function() {
$.ajax({
url: 'http://0.0.0.0:8000/jsonp.js',
dataType: 'jsonp'
});
});
</script>
</body>
</html>
named_callback({ foo: 'bar' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment