【发布时间】:2018-01-27 12:05:18
【问题描述】:
我通过按 ENTER 提交表单时遇到问题。
这就是我的 js 代码的样子:
$.fn.api.settings.api = {
'password_reset': '/account/password_reset/'
}
$('.ui.form')
.form({
fields: {
email: 'empty'
}
})
.api({
action: 'password_reset',
method: 'post',
serializeForm: true,
onSuccess: function () {
$('.page.dimmer').dimmer('show');
console.log('success')
}
})
;
如果我按提交按钮,一切正常,但如果我按 ENTER 提交表单,在控制台中我会得到:
[18/Aug/2017 21:05:20] "POST /account/password_reset/ HTTP/1.1" 200 6
Traceback (most recent call last):
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 255, in send_preamble
('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "c:\users\mihai\miniconda3\Lib\socket.py", line 593, in write
return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] An established connection has been dropped by the software on the host computer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\Mihai\Desktop\dev_place\env\lib\site-packages\django\core\servers\basehttp.py", lin
e 88, in handle_error
super(ServerHandler, self).handle_error()
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\mihai\miniconda3\Lib\socketserver.py", line 625, in process_request_thread
self.finish_request(request, client_address)
File "c:\users\mihai\miniconda3\Lib\socketserver.py", line 354, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "c:\users\mihai\miniconda3\Lib\socketserver.py", line 681, in __init__
self.handle()
File "C:\Users\Mihai\Desktop\dev_place\env\lib\site-packages\django\core\servers\basehttp.py", lin
e 155, in handle
handler.run(self.server.get_app())
File "c:\users\mihai\miniconda3\Lib\wsgiref\handlers.py", line 144, in run
self.close()
File "c:\users\mihai\miniconda3\Lib\wsgiref\simple_server.py", line 36, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
AttributeError: 'NoneType' 对象没有属性 'split'
为什么只有按 ENTER 才会出现此错误?
另外,我没有在控制台中收到“成功”消息。
我使用: Django 11.1, jQuery 3.2.1, 语义-UI 2.2, jQuery serializeObject 2.5.0(用于 serializeForm)。 视窗 8.1
编辑:我将 debug 设置为 true 并开始寻找一些错误:
XHR Aborted (Most likely caused by page navigation or CORS Policy)
我在回溯调用中注意到ConnectionAbortedError: [WinError 10053] An established connection has been dropped by the software on the host computer。
我还没弄明白。
我能做什么?
提前感谢您的回答!
【问题讨论】:
标签: jquery ajax django forms semantic-ui