XMLHttpRequest发送POST请求,见如下代码:
var http = new XMLHttpRequest();
var params = 'data=123'
var url = '';
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
console.log(http.responseText);
}
}
http.send(params);