Issues with FormData Being Null?

前端 未结 2 1992
太阳男子
太阳男子 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:31

    FormData can't be inspected with console.log without iterating.

    Here is an article on how to inspect FormData

    If you want to console.log your FormData object before doing the ajax post request, you can do something like this (I'm using the example from the source docs with your code):

    var form = $('#uploadCSVWithData')[0];
    var data = new FormData(form);
    
    // Display the key/value pairs
    for(var pair of data.entries()) {
       console.log(pair[0]+ ', '+ pair[1]); 
    }
    

提交回复
热议问题