I have a clojure running server whose one endpoint returns simple json.
I make a callback from backbone.js collection to this endpoint. I have put a done handler on the return xhr of the fetch() of collection. However, this done callback is never called. I can see that request is 200 with right data coming to the client.
code is here:
(defn getJson []
{:status 200
:headers {"Content-Type" "application/json"}
:body "[{id: 123, name: \"a2k jailed\"}, {id: 234, name: \"klmno won\"}]"
}
)
(defroutes main-routes*
(GET "/headlines" [] (getJson))
(route/resources "/")
(route/not-found "<h1>404 - Page not found</h1>"))
(def app (compojure.handler/site main-routes*))
(defn -main [port]
(def server (jetty/run-jetty #'app
{:port (Integer. port) :join? false})))
// backbone client side:
this.jsonCollection = new someClassExtendedFrombackboneCollection();
this.jsonCollection.fetch().done(function(jsons) {
console.log("jsons: " + jsons);
});
What is not right in here ?