Created
February 14, 2012 05:26
-
-
Save dsosby/1823881 to your computer and use it in GitHub Desktop.
Jsonp & Clojurescript
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
(def tumblr-url "http://pipes.yahoo.com/pipes/pipe.run?_id=4ddef10340ec6ec0374cbd0f73bce819&_render=json") | |
(defn display-count [json-obj] | |
(let [data (js->clj json-obj :keywordize-keys true) | |
post-count (:count data)] | |
(js/alert (str "Number of posts: " post-count)))) | |
(defn display-items [json-obj] | |
(let [data (js->clj json-obj :keywordize-keys true) | |
items (:items (:value data)) | |
titles (map :title items)] | |
(js/alert (pr-str titles)))) | |
(defn retrieve-tumblr [callback error-callback] | |
(.send (goog.net.Jsonp. tumblr-url "_callback") | |
"" callback error-callback)) | |
(retrieve-tumblr display-items #(js/alert (str "An error occurred: " %))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment