Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to make a json(p) request from ClojureScript using jQuery
(def jquery (js* "$"))
(defn show [msg]
(let [data-as-json ((js* "JSON.stringify") msg nil 4)]
((js* "alert") data-as-json)))
(defn make-js-map
"makes a javascript map from a clojure one"
(let [out (js-obj)]
(doall (map #(aset out (name (first %)) (second %)) cljmap))
(defn doajax []
(.ajax jquery
{:success show
:dataType "jsonp"
:jsonp "jsonp"})))
(.ready (jquery (js* "document"))
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="hello.js"></script>

This comment has been minimized.

Copy link
Owner Author

mjg123 commented Jul 21, 2011

only tested in chrome, btw :)


This comment has been minimized.

Copy link

ilyasjan commented Nov 19, 2015

Thanks mate....;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.