Issues with FormData Being Null?

前端 未结 2 1993
太阳男子
太阳男子 2021-01-25 12:49

I\'m seeming to have an issue with FormData being null. I\'m trying to upload files and JSON in a single POST request. I\'ve tried a variety of things, but nothing has seemed to

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-25 13:18

    Okay I have same problem and I think know the solution after I read this documentation from MDN.

    I fix it with this way:

    var formData = new FormData();
    // After instantiate the object we should use append method
    // And append more data as you needed with this way:
    
    formData.append('prices', $("#columnPrices").val());
    formData.append('id', $("#columnIds").val());
    formData.append('file', $("#uploadCSVWithData");
    
    $(this).html('