import simplejson
...
class HistoryHandler(webapp.RequestHandler):
def get(self):
viewerid = self.request.get('viewerid')
query = "SELECT * FROM dbmodel where viewerid = '" + viewerid + "'"
datas = db.GqlQuery(query)
result = []
for data in datas:
r = {}
r["key"] = data.key().id()
r["unreadflag"] = data.unreadflag
result.append(r)
self.response.out.write(simplejson.dumps(result))
jQuery side:
$.get('http://xxxxxxxx.appspot.com/historydata signed', {viewerid : viewerid}, function(results) {
if(results.length == 0){
...
}
else{
//when results is an object, this "i" is a hash key.
//when results is an array, this "i" is an index.
$.each(results, function(i, r) {
alert(r.unreadflag);
});
}
}, 'json');
P.S.
My English is not good enough.
If there is a mistake and an anxious point,teach me softly.
No comments:
Post a Comment