Skip to content

Instantly share code, notes, and snippets.

@aarkerio
Last active August 27, 2018 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarkerio/a4ddc4b747e346a777e936c09f5b0f91 to your computer and use it in GitHub Desktop.
Save aarkerio/a4ddc4b747e346a777e936c09f5b0f91 to your computer and use it in GitHub Desktop.
ClojureScript Ajax POST
(defn set-message [response]
(.log js/console (str ">>> RESPONSE #####" response)))
(defn error-handler [response]
(.log js/console (str ">>> RESPONSE #####" response)))
(defn save-json []
(let [json (.-value (gdom/getElement "json-field"))
id (.-value (gdom/getElement "upload-id"))
csrf-field (.-value (gdom/getElement "__anti-forgery-token"))]
(POST "/admin/uploads/save"
{:params {:body json
:id id}
:headers {"x-csrf-token" csrf-field}
:handler set-message
:error-handler error-handler})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment