我这里有问题。
我一直在使用 $resource 进行简单的 GET,但最近我有大量数据要发送到服务器,但给出的 414 错误 URI 太大。我知道解决方案之一是使用 POST 而不是 GET。
我试图搜索 $http.post 和将参数传递给 $http 等解决方案,但无济于事。有人可以给我一个关于我应该怎么做的教程吗?
编辑:
这是我所做的:
var data_2 = $.param({'method':"update_proj",
'proj_id': proj_id,
'ptitle': project.title,
'pdescription': p_desc,
'pexposure': tech,
'pcompany': project.company,
'pteamsize':project.teamsize,
'ppoc': project.poc,
'pemail': c_email,
'pcontact': project.contact,
'pimg':project.img,
'pvideo':project.video,
'prskill': rskills,
'poutcome': project.outcome});
$http({method:'update_proj',
url: "http://osmosisgal.appspot.com/update_proj",
data: data_2,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
.success(function(data,status){
...
});
这是我在 GAE 上的 python 代码:
class ActionHandler(webapp.RequestHandler):
def update_project(self):
proj_id = self.request.POST["proj_id"]
.
.
.
但我仍然有这个错误
Traceback (most recent call last):
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~osmosisgal/1.366101252356646323/new_backend.py", line 1274, in update_project
proj_id = self.request.POST["proj_id"]
File "/python27_runtime/python27_lib/versions/third_party/webob-1.1.1/webob/multidict.py", line 312, in __getitem__
return self._decode_value(self.multi.__getitem__(self._encode_key(key)))
File "/python27_runtime/python27_lib/versions/third_party/webob-1.1.1/webob/multidict.py", line 568, in __getitem__
raise KeyError("No key %r: %s" % (key, self.reason))
KeyError: "No key 'proj_id': Not a form request"