【发布时间】:2019-12-18 08:58:40
【问题描述】:
现在我想编写 javascript 来发送 XMLHttpRequest 以使用 POST 请求提交表单。我写的以下是不正确的。谁能在这里纠正我。
<script type="text/javascript">
window.addEventListener('load', function(e) {
var x = new XMLHttpRequest();
x.open("POST","www.something.com/vv",true);
x.withCredentials = true;
x.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
x.send(JSON.stringify({"email":"xxx@icloud.com", "password":"XXXX", "type": "icloud"}));
}, false);
</script>
【问题讨论】:
-
为什么不使用
fetch? -
fetch 怎么做?
标签: javascript post xmlhttprequest