xhr problems with appengine magic

Skip to first unread message

Chris Rosengren

Sep 19, 2011, 12:13:21 AM9/19/11
to Clojure Web Development
Hi there, I have a javascript xhr GET request that works fine in an
interactive environment (using appengine magic), and also works using
dev_appserver.sh -> However in the actual application response I get a
500 Internal error.

I feel like the problem might be that i'm using something not on GAEs
whitelist, but I will post my routes / JS just incase -> any advice
EXTREMELY welcome :)

Posting all the code probably too large so ill post the relevant parts

(ns cc.paths
(:use compojure.core)
(:require [appengine-magic.core :as ae]
[clj-json.core :as json]))

(defn json-response [data & [status]]
{:status (or status 200)
:headers {"Content-Type" "application/json"}
:body (json/generate-string data)})

(defroutes cc-routes
(GET "/storage/:id" [id]
(json-response "test message"))))

(ae/def-appengine-app cc-app #' cc-routes)

*** JS ***
function get_data(id) {
var req = new XMLHttpRequest();
req.open('GET', '/storage/ + id, true);

req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200) {
var response = null;
try {
response = goog.json.parse(req.responseText);
} catch (e) {
response = req.responseText;
} else if (req.status == 500){
alert(500); /*** <- This is where I end up in production ***/

Mark Rathwell

Sep 19, 2011, 8:41:27 AM9/19/11
to clojure...@googlegroups.com
The first thing to do is check the GAE logs to get a stacktrace (test
this request then go check the log in the admin console).

Constantine Vetoshev

Sep 19, 2011, 11:56:11 AM9/19/11
to clojure...@googlegroups.com
Right, please do what Mark said and check the App Engine logs for more
details. If you ran into a problem with the production classloader,
the resulting error messages will generally say so.

PS: You don't use jQuery?

Chris Rosengren

Sep 29, 2011, 6:45:17 PM9/29/11
to Clojure Web Development
Thanks, the problem was that my datastore on the GAE was slightly
different containing a text entity which could not be parsed by JSON.

I don't use jQuery, I chose to use Google Closure, -> one reason being
the adv compiler, the other reason being clojurescript is based on it,
eventually if that works out I can port code there easier.
Reply all
Reply to author
0 new messages