jquery - Getting NoneType error on form submit with ajax -
i have problem when submit form through pressing enter.
this how js code looks like:
$.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') } }) ; if press submit button, works alright, if submit form pressing enter, in console get:
[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] established connection has been dropped software on host computer during handling of above exception, 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 not subscriptable during handling of above exception, 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' object has no attribute 'split'
why getting error pressing enter?
also, i'm not getting 'success' message in console.
i use: django 11.1, jquery 3.2.1, semantic-ui 2.2, jquery serializeobject 2.5.0 (for serializeform). windows 8.1
edit: set debug true , started errors: xhr aborted (most caused page navigation or cors policy)
i noticed connectionabortederror: [winerror 10053] established connection has been dropped software on host computer in traceback call.
i haven't figured out yet.
what can do?
thanks in advance answers!
i found solution.
the problem when press enter, .preventdefault() not called.
a person on github came with:
$("#form").keypress(function(event) { if (event.which == 13) { event.preventdefault(); } }); now it's working fine, wow, huge error preventdefault().
Comments
Post a Comment