jquery ajax to python GAE -
i have basic google app engine project using python. implement sort of logging on site (i understand google app engine has kind of feature). in future add high scores of games using same idea. logging have basic page.py contains this:
from google.appengine.api import users google.appengine.ext import ndb import webapp2 import json class save(ndb.model): time = ndb.datetimeproperty(auto_now_add=true) url=ndb.stringproperty() user=ndb.stringproperty() class mainpage(webapp2.requesthandler): def post(self): data = json.loads() self.stuff.url=(data) self.stuff.put() app = webapp2.wsgiapplication([ ('/page.py', mainpage), ], debug=true)
this test before implement entire thing. want save date, user, , page title in logs. know how other things. want jquery in html send page title python file. here jquery.
$.ajax({ type: "post", url: "/page.py", datatype: 'json', data: ('index') })
i have understanding of html, first time have played jquery , json, have understanding of python well.
my questions. how ajax file transfer supposed work? need parameter json.loads() be, how work? simple example appreciated.
i have done google searches , stack overflow searches, have not found simple explanation , example.
thanks in advance.
elijah
you can use
class mainpage(webapp2.requesthandler): def post(self): data = self.request.body args = json.loads(data) .... , put data ....
but why not use: https://cloud.google.com/appengine/docs/python/endpoints/
or start here: https://www.youtube.com/watch?v=uy0tp6_kwj4
Comments
Post a Comment