Problems with Getting Remote Contents using Google App Engine
Posted
by
dade
on Stack Overflow
See other posts from Stack Overflow
or by dade
Published on 2011-01-10T22:39:01Z
Indexed on
2011/01/10
22:53 UTC
Read the original article
Hit count: 195
Here is the client side code. It is running insdide a Google Gadgets
var params = {};
params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
var url = "http://invplatformtest.appspot.com/getrecent/";
gadgets.io.makeRequest(url, response, params);
The response function is:
function response(obj)
{
var r = obj.data;
alert(r['name']);
}
while on the server end, the python code sending the JSON is:
class GetRecent(webapp.RequestHandler):
def get(self):
self.response.out.write({'name':'geocities'}) #i know this is where the problem is so how do i encode json in GAE?
which is just supposed to send back a Json encoded string but when i run this, the javascript throws the following error:
r is null
alert(r['name']);
If i were recieving just TEXT contents and my server send TEXT everything works fine. I only get this problem when am trying to send JSON. Where exactly is the problem? Am i encoding the JSON the wrong way on AppEngine? I tried using the JSON library but it looks as if this is not supported.
Where is the problem exactly? :(
© Stack Overflow or respective owner