I\'m new to clojurescript and would like to do a deeper dive by implementing a previously written application purely in clojurescript, but am at a loss with respect to to implem
The way I did it is slightly different. I don't know why the way that Marc suggested in his answer didn't work for me. Hopefully this is also useful.
I used goog.net.XhrIo
directly, rather than the xhr-connection
wrapper.
(defn callback [reply]
(let [v (js->clj (.getResponseJson (.-target reply)))] ;v is a Clojure data structure
(your-function-here v)))
(.send goog.net.XhrIo url callback)
The main difference that I can see is that I've used .-target
to get the property of the JSON object, rather than calling target
.
It's worth noting that maps in v
that have been created from JSON objects are keyed by strings not keywords.