user5020522
user5020522

Reputation:

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?

Upvotes: 1

Views: 1186

Answers (1)

Quentin
Quentin

Reputation: 943500

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.

Upvotes: 2

Related Questions