javascript
function sendDataToServer() {
var xhr = new XMLHttpRequest();
var url = "e.com/api/data";
var data = { key: 'value' };
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
console.log(xhr.responseText);
}
};
xhr.send(JSON.stringify(data));
}
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-