首页 > 解决方案 > 使用 AJAX 上传 CSV 文件时出现内部服务器错误 500

问题描述

我有一个非常简单的网络应用程序,用于将 CSV 文件上传到我的服务器。为此,我在 DJANGO 下使用 AJAX 和 JQUERY:

function Upload_Bonds(){
        var csrftoken = getCookie('csrftoken');
        var formData = new FormData(document.getElementById("formUploadBonds")); 
        var add_answer = confirm("Confirm uploading and processing of csv File?" );
        if (add_answer) {
               $.ajax({
                    url: "/cvs/DealStore/upload_bonds/", 
                    type: "POST", 
                    data: formData, 
                    async: false,
                    cache: false,
                    contentType: false,
                    enctype: 'multipart/form-data',
                    processData: false,
                    success: function (data) {
                        $('#message').html("<p class='text-center text-success font-weight-bold'>Success</p>");
                        window.alert("Data populated, please check the Bonds list table!");
                     },
                     error: function(data) {
                          $("#message").html("<p class='text-center text-danger font-weight-bold'>Failed</p>");
                     }
                   });
               }
      }    

但是,每次我尝试使用该功能时,我都会收到 POST 500(内部服务器错误)。我能够在浏览器控制台上捕获以下内容:

在此处输入图像描述

关于如何处理此错误的任何想法?我将应用程序部署在另一台服务器上并且工作正常。所以也许是关于服务器配置的东西。(我正在使用 Linux 服务器)

谢谢!

标签: javascripthtmljquerydjangoajax

解决方案


推荐阅读