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