Created
March 18, 2011 20:59
-
-
Save nolman/876825 to your computer and use it in GitHub Desktop.
This file contains 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
class ExamplesController < ApplicationController | |
def show | |
data = {:name => "Apple Pie", :price => "3.75"} | |
render :json => data, :callback => params[:callback] | |
end | |
end |
This file contains 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
<script type='text/javascript' src='http://www.anotherdomain.com/examples/1?callback=callback1234'></script> |
This file contains 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
<script type='text/javascript' src='http://www.anotherdomain.com/examples/1?callback=callback1234'> | |
callback1234({'name':'Apple Pie', 'price':'3.75'}); | |
</script> |
This file contains 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> | |
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'></script> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
$.getJSON("http://www.anotherdomain.com/examples/1?callback=?", function(data){ | |
console.log(data); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
JSONP | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment