我正在尝试不使用odoo的ajax调用来进行简单的ajax调用,如下所示:
控制器:
@http.route('/consentimento.privacidade/ok', auth="none", type='json', csrf=False)
def aceitar(self):
http.request.session.aceitar = True
return True
还有我的jquery:
$(".btnpolitica").click(function(){
$.ajax({
url: '/consentimento.privacidade/ok',
dataType: 'json',
type: 'POST',
data: JSON.stringify(Date.now()),
contentType: 'application/json'
});
});
我已经尝试了多种方法,花了好几天的时间,但是看来它不能通过简单的ajax调用来工作。...我在做什么错了?
给我的错误:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/odoo/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/odoo/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/odoo/http.py", line 1306, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo/odoo/http.py", line 1280, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/site-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/http.py", line 1439, in dispatch
request = self.get_request(httprequest)
File "/opt/odoo/odoo/http.py", line 1379, in get_request
return JsonRequest(httprequest)
File "/opt/odoo/odoo/http.py", line 605, in __init__
self.params = dict(self.jsonrequest.get("params", {}))
AttributeError: 'int' object has no attribute 'get'