Created
January 21, 2012 14:02
-
-
Save ryanmcgrath/1652861 to your computer and use it in GitHub Desktop.
$.ajax breakdown for cross-domain requests.
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
// An AJAX query is broken down like this... | |
$.ajax({ | |
// This means we're going to pull data; if you're | |
// creating something new on the server, this'll be POST | |
type: "GET", | |
// This tells jQuery to use a cross-domain fetching trick | |
dataType: "jsonp", | |
// The BASE URL we want to query data from | |
url: '', | |
// The params object you created | |
data: { /* your object here */ }, | |
// A function to call when the query is completed | |
success: function(tweets) { | |
// Do stuff | |
}, | |
// A function to call if things blow up completely - like Twitter is down | |
error: function() { | |
alert("OH GOD THE TWITTERS IS DOWN"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment