javascript - Tornado doesn't send Ajax response to client -
upon form submit tornado server checks , sends response client, should appear in current page alert
.
instead blank html page rendered json
response, not alert
on current page form submitted.
on submit form sent via post
/dh (datahandler)
this jquery:
$.post("/dh",function(data,status){ alert("data: " + info + "\nstatus: " + status); },"json");
the tornado code:
class datahandler(basehandler): def post(self): # checks done form info received dupinfo={ 'tel' : duptel, 'name' : dupname } self.write(json.dumps(dupinfo, default=json_util.default)) self.finish()
so how can homecoming json current page?
after "alert" statement, add together return false;
. disables browser's default handling of post event. browser's default behavior navigate new url, , want prevent that.
javascript jquery python tornado
No comments:
Post a Comment