从ajax请求接收空的MultiDict

时间:2019-04-01 08:17:05

标签: javascript python jquery html ajax

我正在尝试使用ajax查询上传文件,但无法正常工作。我在后端得到一个空的MultiDict。

HTML:

<form id="fileinfo" enctype="multipart/form-data" method="post" action="">
<input type="file" name="fileToUpload" id="fileToUpload" accept=".xlsx, .xls" required/>
<input type="button" value="Upload File" onclick="function()">
</form>

Ajax函数:

{
 var formData = new FormData(document.getElementById('fileinfo')[0]);
 formData.append("file",$("fileinfo")[0].files[0])
 add_ajax_count();
 new Ajax.Request("url_to_upload", {
     method : "POST",
     processData: false,
     data : formData,
     onComplete:function(transport){
          remove_ajax_count();
          check_ajax_count();
          alert('Submitted!');
          return processResultManage(transport.status, transport, verb,  resource);
     },
     error: function(){
          alert("error in submission");
    }
 });
}

0 个答案:

没有答案