View added values in the Formdata Object and remove

Asked

Viewed 206 times

1

I often tried to debug an object instance FormData, but I cannot see the values stored by the method append.

I tried that:

f = new FormData();

f.append('name', 'Wallace Maxters');

f.append('image', $('#file').prop('files')[0]);

// tento obter o conteúdo adicionando

f.toString() //"[object FormData]"

console.log(f['name']) // undefined

How can I view the values I have stored inside an object instance FormData? Is there any way to do that?

How would you remove the "name" value by adding to the example object above?

1 answer

1


The formData does not allow to remove information after it has been inserted.

If you want to make sure you have the right content you have to make a separate object and then convert to formData.

There are some answers in Soen (this or this) on this and interestingly the specification of the W3C points to new features in the future... beyond the .append() there will be has, delete, get, getAll and set. Let’s see when it’s implemented.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.