2021-02-08 jquery调用ajax获取Respons

2021-02-08  本文已影响0人  jinya2437

网上找了好多好多资料,获取想要头部信息....22222..直接贴代码,已测试可用

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>获取PPT总页数</title>
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script type="text/javascript"> 
        $.ajax({
            type: 'GET',
            url: "http://xyz-1253118816.cos.ap-guangzhou.myqcloud.com/2021/02/07/161269131415570360.pptx?ci-process=doc-preview&page=1",
            success: function(data,status,xhr){
                var headers = xhr.getAllResponseHeaders();
                var arr = headers.trim().split(/[\r\n]+/);
                var headerMap = {};
                arr.forEach(function (line) {
                    var parts = line.split(': ');
                    var header = parts.shift();
                    var value = parts.join(': ');
                    headerMap[header] = value;
                });
                console.info(headerMap);
                //头部返回PPT总页数 
                console.info(headerMap['x-total-page']);
           }
        });

</script>
 </head>
 <body>
  
 </body>
</html>

上一篇下一篇

猜你喜欢

热点阅读