【发布时间】:2015-01-06 11:34:17
【问题描述】:
问题: 出现错误 404。我认为问题在于形成 URL。拜托,谁能指出我的错误。我已经尝试了一段时间的不同变体,但无法使其正常工作。
我的代码摘录:
服务器
class Nearest_banks(webapp2.RequestHandler):
def main_func(self):
body_values = {
'radius': default_radius,
}
template = jinja_env.get_template('nearest_banks.html')
self.response.out.write(template.render(body_values))
def get(self):
# some code here
def post(self, entered_radius):
return webapp2.Response('Done')
application = webapp2.WSGIApplication([
webapp2.Route(r'/nearest_banks', handler=Nearest_banks, name='n_banks', handler_method='main_func'),
webapp2.Route(r'/nearest_banks/default_radius', handler=Nearest_banks, name='default_radius', handler_method='get'),
webapp2.Route(r'/nearest_banks/radius/(\d+)', handler=Nearest_banks, name='new_radius', handler_method='post'),
], config=session_module.config, debug=True)
客户
$( "#change_radius" ).click(function(){
var new_radius = $("#radius").val();
$.ajax({
type: "post",
url: '/nearest_banks/radius/' + new_radius,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
$("#places").html("OKKK");
},
error: function(){
alert("error");
}
});
【问题讨论】:
标签: jquery python ajax google-app-engine