简体   繁体   中英

Why is my FormData object empty?

When I run

var data = new FormData();
data.append("somekey", "somevalue");
console.log("data = " + JSON.stringify(data)); // TEST

I get empty braces printed to the console. Why is this?

The FormData API doesn't include anything to expose the content of it back to the client.

It isn't empty. You just don't have a way to look at what is inside it.

The data you have appended will still appear when you send() it with XMLHttpRequest .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM