没有在节点应用程序的ajax中获得任何POST响应

时间:2018-04-24 07:32:52

标签: jquery node.js ajax

我有这个AJAX方法,在这里我导入一个CSV文件,但我无法得到任何响应相同的代码在LINUX OS中执行每当我尝试在Windows中尝试它不工作意味着不发送响应

AJAX方法:

 uploadUsers: function(data) {
     return $.ajax({
         url: "/api/importusers",
         type: "POST",
         data: data,
         contentType: false,
         cache: false, 
         processData: false,
     })
 }

AJAX代码:

$('#upload-users-frm').submit(function (e) {
    e.preventDefault();
    var data = new FormData(this)
    app.uploadUsers(data).done(function (response) {
        if ($.validateResponse(response)) {
            if (response.status == true) {
                if (response.message != '') {
                    Materialize.toast(response.message, 4000, '')
                }

                if (response.importError == true) {

                    $.showValidationMessage(response.ImportErrorMessage)
                }
            } else {
                $.showValidationMessage(response.message)
            }
        }
    })
})

表单代码:

<form id="upload-users-frm">
    <div class="file-field input-field">
        <div class="btn">
            <span>Upload Users</span>
            <input type="file" name="file" id="upload-user" 
                   class="import-file" accept=".csv, 
                   application/vnd.openxmlformats-o 
                   fficedocument.spreadsheetml.sheet, application/vnd.ms-excel">
        </div>
        <div class="file-path-wrapper">
            <input class="file-path validate import-file" type="text" > 
        </div>
    </div>
</form>

0 个答案:

没有答案