Created
May 26, 2010 12:38
-
-
Save swinton/414418 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
<h1>Hello, here is an example of using JSONP within a Facebook page</h1> | |
<p>This is based on the example from the <a href="http://wiki.developers.facebook.com/index.php/FBJS/Examples/Ajax">Ajax examples</a> in the wiki.</p> | |
<div id="spotlight"> | |
result should load here... | |
</div> | |
<script> | |
// 1. Instantiate our Ajax instance | |
var ajax = new Ajax(); | |
var spotlightDiv = document.getElementById("spotlight"); | |
spotlightDiv.setInnerFBML("testing..."); | |
ajax.responseType = Ajax.JSON; | |
// 2. Set up handlers | |
ajax.ondone = function(data) { | |
spotlightDiv.setInnerFBML("yay!"); | |
}; | |
ajax.onerror= function(data) { | |
spotlightDiv.setInnerFBML("yah boo sucks to you!"); | |
}; | |
// 3. Make the request | |
ajax.post('http://c4.labs.nixmc.com/spotlight.json'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment