Skip to content

Instantly share code, notes, and snippets.

@bittersweetryan
Created September 4, 2012 02:54
Show Gist options
  • Save bittersweetryan/3616012 to your computer and use it in GitHub Desktop.
Save bittersweetryan/3616012 to your computer and use it in GitHub Desktop.
getTweets
var getTweets = function(searchURL){
return $.Deferred(function(dfd){
$.ajax({
url : searchURL,
dataType : 'jsonp',
success : function(data){
//make sure what we got back valid data from twitter
if(typeof data === 'object' && ! ('error' in data)){
dfd.resolve(data.results);
}
else{
//we can pass variables to our callbacks
dfd.reject('bad response from server');
}
},
error : function(){
dfd.reject('ajax error');
}
});
}).promise();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment