如何使用参数

时间:2016-08-13 03:18:15

标签: javascript

我尝试使用参数在JavaScript中发送表单提交的HTPP请求。它位于浏览器控制台中。它看起来像这样:

params,(My parameters...)
        some:some;
        some:some;
        some:some;
Header,
       asusaul;
Post,(the form submit)

1 个答案:

答案 0 :(得分:0)

您可以使用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);