Javascript Jquery表单以错误的方式发送数据

Javascript Jquery表单以错误的方式发送数据,javascript,jquery,express,ajaxsubmit,Javascript,Jquery,Express,Ajaxsubmit,我使用vue资源模块发送POST请求,使用jquery表单插件发送到相同的路由,但带有文件 这是我的密码 function sendWithoutFiles(data){ return this.$http.post(link, data) } function sendWithFiles(data){ return new Promise(function(resolve, reject){ jQuery('#form').ajaxSubmit({

我使用vue资源模块发送POST请求,使用jquery表单插件发送到相同的路由,但带有文件

这是我的密码

function sendWithoutFiles(data){
    return this.$http.post(link, data)
}
function sendWithFiles(data){
    return new Promise(function(resolve, reject){
        jQuery('#form').ajaxSubmit({
            data: data,
            success: resolve,
            url: link
        })
    })
}

function send(data){
    var sendFunction = sendWithoutFiles;
    if(files)
        sendFunction = sendWithFiles;
    sendFunction({
        message: 'john',
        participants: [1, 50]
    }).then(function(res){
        console.log(res);
    })
}
现在,如果我不带文件发送它们,那就完美了。 但当我这样做时,数据是这样到达的:

{
    message: ['john'],
    'participants[]': [1, 50]
}
我将express与多方一起使用,如下所示:

app.post('*', function(req, res, next){
    var form = new multiparty.Form();
    form.parse(req, function(err, fields, files){
        req.uploadFiles = files;
        console.log(fields, req.body, "MID LOG");
        req.body = req.body || fields;
        next();
    })
})
在chrome网络面板->请求有效负载中 所以我不认为多党模式有什么问题


我是否对jquery插件做了一些错误的事情

如果(文件)sendFunction=sendWithoutFiles,则设置
这是堆栈上的一个错误。在我的代码中是正确的。我更新了我的问题。很抱歉,您正在尝试发布两种不同的类型1.2。同一请求中的多部分数据。这是不可能的,我希望…?既然你不能同时发布数据和文件?