Skip to content

Instantly share code, notes, and snippets.

@shyblower
Created December 23, 2011 20:54
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 shyblower/1515333 to your computer and use it in GitHub Desktop.
Save shyblower/1515333 to your computer and use it in GitHub Desktop.
clojurescript client side remoting
(ns client.html.api.utils
(:use [client.html.utils :only [clj->js]]))
(def $ js/$)
(def ajax-options {:timeout 30000})
(defn remote [type url data & {:keys [on-success on-error]}]
(->
(.ajax $ url
(clj->js (assoc ajax-options
:type (name type)
:data (clj->js data))))
(#(if on-success (.done % on-success) identity))
(#(if on-error (.fail % on-error) identity))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment