Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
FormData无法发送Javascript_Javascript_Xmlhttprequest_Form Data - Fatal编程技术网

FormData无法发送Javascript

FormData无法发送Javascript,javascript,xmlhttprequest,form-data,Javascript,Xmlhttprequest,Form Data,我试图发送一个简单的表格到一个网站,期待它。我在youtube视频上找到了这段代码,它对他起了作用。这是我第一次使用FormData,我不知道会出什么问题 镜头: 网络: 控制台: 不久前,我在使用jquery进行项目时遇到了同样的问题,如果您更改此选项,它可能会对您起作用: xhr.open("POST", "correcturlnothingwronghere",true); 为此: xhr.open("POST", "correcturlnothingwronghere",false

我试图发送一个简单的表格到一个网站,期待它。我在youtube视频上找到了这段代码,它对他起了作用。这是我第一次使用FormData,我不知道会出什么问题

镜头:

网络:

控制台:


不久前,我在使用jquery进行项目时遇到了同样的问题,如果您更改此选项,它可能会对您起作用:

xhr.open("POST", "correcturlnothingwronghere",true);
为此:

xhr.open("POST", "correcturlnothingwronghere",false); 

在发送之前,您需要设置正确的http头

xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

网络选项卡屏幕截图显示
ERR\u NAME\u NOT \u RESOLVED
,因此URL肯定有问题。我的公司给了我URL,我无法更改它或其他任何内容。添加了这一点,但它没有更改任何内容。
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');