jquery ajax 请求获取所有响应头信息

<script src="//statics.1024tools.com/libs/jquery/1.11.1/jquery-1.11.1.min.js"></script>


function initResponseHeaders() {
	$.ajax({
		'type': 'head',
		'url': 'https://1024tools.com/header',
		'success': function(data,status,xhr){
			$('#response').text(xhr.getAllResponseHeaders());
		},
		'error': initResponseHeaders
	})
}


效果如下
Server: nginx
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Cache-Control: no-cache
Date: Tue, 28 Jun 2016 06:36:11 GMT
Content-Encoding: gzip

猜你喜欢

转载自dragonmandance.iteye.com/blog/2307789