当我在scripty.js
文件和main.py
文件中添加了一些代码时,我的POST函数出现了一些问题:
在脚本.js公司名称:
var form = $('#register-form').serialize();
$.ajax({
url: '/postreg',
type: 'POST',
data: form,
success: function (res) {
res.preventDefault()
console.log("done");
}
});
以及主.py公司名称:
^{pr2}$我的结果是:
127.0.0.1:55126 - - [01/Apr/2019 18:37:25] "HTTP/1.1 GET /static/js/ripples.min.js.map" - 200
Traceback (most recent call last):
File "/home/amir/.local/lib/python3.6/site-packages/web/utils.py", line 70, in __getattr__
return self[key]
KeyError: 'username'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/amir/.local/lib/python3.6/site-packages/web/application.py", line 257, in process
return self.handle()
File "/home/amir/.local/lib/python3.6/site-packages/web/application.py", line 248, in handle
return self._delegate(fn, self.fvars, args)
File "/home/amir/.local/lib/python3.6/site-packages/web/application.py", line 488, in _delegate
return handle_class(cls)
File "/home/amir/.local/lib/python3.6/site-packages/web/application.py", line 466, in handle_class
return tocall(*args)
File "/home/amir/PycharmProjects/SocialWeb/Controller.py", line 27, in POST
return data.username
File "/home/amir/.local/lib/python3.6/site-packages/web/utils.py", line 72, in __getattr__
raise AttributeError(k)
AttributeError: 'username'
127.0.0.1:55124 - - [01/Apr/2019 18:37:30] "HTTP/1.1 POST /postreg" - 500 Internal Server Error
这是我的注册表表单HTML文件
查询序列化使用输入
name
属性,而不是id
属性。您的html代码段似乎不包含name="username"
之类的内容。在来自jquery文档:
相关问题 更多 >
编程相关推荐