Answers for "add data to formdata"

1

add formdata javascript

var formData = new FormData();

formData.append("username", "Groucho");
formData.append("accountnum", 123456); // number 123456 is immediately converted to a string "123456"

// HTML file input, chosen by user
formData.append("userfile", fileInputElement.files[0]);

// JavaScript file-like object
var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file...
var blob = new Blob([content], { type: "text/xml"});

formData.append("webmasterfile", blob);

var request = new XMLHttpRequest();
request.open("POST", "http://foo.com/submitform.php");
request.send(formData);
Posted by: Guest on August-15-2020
0

diff bw formdata.set and formdata.append

The difference between set() and FormData. 
append is that if the specified key does already exist, 
set() will overwrite all existing values with the new one, 
whereas FormData. append will 
append the new value onto the end of the existing set of values.
Note: This method is available in Web Workers.
Posted by: Guest on April-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language