“JavaScript FormData” Code-Antworten

JQuery Form -Daten

var fd = new FormData();    
fd.append( 'file', input.files[0] );

$.ajax({
  url: 'http://example.com/script.php',
  data: fd,
  processData: false,
  contentType: false,
  type: 'POST',
  success: function(data){
    alert(data);
  }
});
Stupid Sheep

Fügen Sie FormData JavaScript hinzu

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);
Ugly Unicorn

JavaScript FormData

var form = $('form')[0]; // You need to use standard javascript object here

const oData = new FormData(form);
console.log(oData);
Singh99

Ähnliche Antworten wie “JavaScript FormData”

Fragen ähnlich wie “JavaScript FormData”

Weitere verwandte Antworten zu “JavaScript FormData” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen