Google Appengine&jQuery:错误414(请求的URI太长)

SM7*_*M79 0 jquery post google-app-engine

我在使用JQuery Ajax将数据发布到本地appengine应用程序时遇到问题.这是简化的客户端代码:

text_to_save = 'large chunk of html here'
req = '/story/edit?story_id=' + story_id + '&data=' + text_to_save;
$.post(req, function(data) {
    $('.result').html(data);
});
Run Code Online (Sandbox Code Playgroud)

这是简化的服务器端代码:

class StoryEdit(webapp.RequestHandler):
    def post(self):
        f = Story.get(self.request.get('story_id'))
        f.html = self.request.get('data')
        f.put()
Run Code Online (Sandbox Code Playgroud)

错误是414(请求的URI太长).我究竟做错了什么?

the*_*ega 6

不要使用GET将数据发送到服务器,而是使用POST!虽然您使用的是POST,但数据是通过Request-Parameters提交的,但这些数据的大小有限.

尝试

text_to_save = 'large chunk of html here'
req = '/story/edit?story_id=' + story_id;
$.post(req, {data: text_to_save});
Run Code Online (Sandbox Code Playgroud)