Created
September 4, 2012 02:54
-
-
Save bittersweetryan/3616012 to your computer and use it in GitHub Desktop.
getTweets
This file contains hidden or 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
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