ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的

本地发送邮件的一个问题,是ajax问题。但是我测试未成功

图片.png

PS D:\django\2\dailyfresh> python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
March 26, 2020 - 17:40:21
Django version 1.11, using settings 'dailyfresh.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[26/Mar/2020 17:40:29] "GET / HTTP/1.1" 200 11209
[26/Mar/2020 17:40:29] "GET /static/css/reset.css HTTP/1.1" 200 664
[26/Mar/2020 17:40:29] "GET /static/js/slideshow.js HTTP/1.1" 404 1658
[26/Mar/2020 17:40:29] "GET /static/css/main.css HTTP/1.1" 200 22992
Traceback (most recent call last):
  File "E:\tools2\02_python3.5\lib\wsgiref\handlers.py", line 138, in run
    self.finish_response()
  File "E:\tools2\02_python3.5\lib\wsgiref\handlers.py", line 181, in finish_response
    self.write(data)
  File "E:\tools2\02_python3.5\lib\wsgiref\handlers.py", line 275, in write
    self.send_headers()
  File "E:\tools2\02_python3.5\lib\wsgiref\handlers.py", line 333, in send_headers
    self.send_preamble()
  File "E:\tools2\02_python3.5\lib\wsgiref\handlers.py", line 256, in send_preamble
    ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
  File "E:\tools2\02_python3.5\lib\wsgiref\handlers.py", line 454, in _write
    result = self.stdout.write(data)
  File "E:\tools2\02_python3.5\lib\socket.py", line 594, in write
    return self._sock.send(b)
ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的连接。
[26/Mar/2020 17:40:29] "GET /static/js/slideshow.js HTTP/1.1" 404 1658
[26/Mar/2020 17:40:29] "GET /static/css/reset.css HTTP/1.1" 500 59
$.ajax({
                  url:"{% url 'article:article_post' %}",
                  {#一定不要写成小写了,坑了好久#}
                  type: 'POST',
                  mimeType: "multipart/form-data",
                  {#告诉jQuery不要去处理发送的数据, 发送对象。#}
                  processData : false,
                  {#告诉jQuery不要去设置Content-Type请求头#}
                  contentType : false,
                  async : false,
                  data: formData,
})

原因:ajax默认是异步提交,可是有时候我们会发现,本来要求请求马上出现,可是异步会导致后面突然再执行,这样就出问题了。
ajax请求时加上

async : false,

function jie(){
        $.ajax({
            url:"http://127.0.0.1:8000/userctrl/orders",
            data:{'user':$.cookie("username"),"good_name":$(".good_name").text(),},
            type:"post",
            async:false,
            dataType:"text",
       success:function(obj){

        })
     })
    }

你可能感兴趣的:(ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的)