返回列表

Content-type

默认分类 2015/11/02 20:15

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
function doit() {
    var xhr = new XMLHttpRequest();
    var url = 'http://127.0.0.1:3000/api/aa?a=1&b=2'
    xhr.open('POST', url, true);
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
            alert(xhr.responseText);
        }
    }
    xhr.send('c=3');
}
</script>
</head>

<body>
<button onclick="doit()">doit</button>
</body>

</html>