var xhr = new XMLHttpRequest();
xhr.open('get', '请求的url')
xhr.send();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.readyState == 200) {
console.log('返回数据成功:' + JSON.stringify(xhr.responseText));
}
};
var xhr = new XMLHttpRequest();
xhr.open('get', '请求的url地址')
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.send('name=fox%age=18');
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.readyState == 200) {
alert(xhr.responseText);
}
};
console