Display values adding to the FormData object and remove

1

I have often tried to debug an instance of the FormData object, but I can not see the values stored by the append method.

I tried this:

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 instance of the FormData object? Is there any way to do this?

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

    
asked by anonymous 01.06.2015 / 19:56

1 answer

1

formData does not allow you 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 it to formData.

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

    
01.06.2015 / 20:32