[javascript]XMLHttpRequest GET/SET HTTP头与改变HTTP METHOD示例代码

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <script type="text/javascript" src="./ad_add_js/jquery-1.8.3.js"></script>
</head>
<body>
<input type="file" name="" id="file1">
<script type="text/javascript">
    function reqListener () {
      console.log(this.responseText);
    }
    function responser() {
      console.log(this.getResponseHeader("Server"));
      console.log(this.getResponseHeader("X-Powered-By"));
    }

    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
    oReq.open("PUT", "http://192.168.88.207:10003/temp_163.php");
    oReq.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=1.8");
    oReq.setRequestHeader("Content-Type", "text/plain1");
    oReq.setRequestHeader("Customize", "Shot faster");
    oReq.onload = responser;
    oReq.send();
</script>
</body>
</html>

 

posted @ 2018-10-11 11:04  yiyide266  阅读(1647)  评论(0编辑  收藏  举报