猿问

jquery ajax 怎么获得返回的response headers

jquery ajax 怎么获得返回的response headers


杨魅力
浏览 7301回答 3
3回答

幕布斯6054654

123456789101112131415161718回答的步奏如下:$.ajax({        cache: false,        type: "POST",        url: "/camera_face_register.aspx",        data: {            Person_id: document.getElementById("pid01").value,            Person_Name: document.getElementById("pname01").value,            Group_id: document.getElementById("pgid01").value,            Custom_key: document.getElementById("pkey01").value,            Photo: imgdata        },        dataType: 'multipart/form-data',        async: true,        success: function(data, textStatus, request){              alert(request.getResponseHeader('some_header'));        }    });

HUH函数

$.ajax({type: 'HEAD', // 获取头信息,type=HEAD即可url : window.location.href,complete: function( xhr,data ){// 获取相关Http Response headervar wpoInfo = {// 服务器端时间"date" : xhr.getResponseHeader('Date'),// 如果开启了gzip,会返回这个东西"contentEncoding" : xhr.getResponseHeader('Content-Encoding'),// keep-alive ? close?"connection" : xhr.getResponseHeader('Connection'),// 响应长度"contentLength" : xhr.getResponseHeader('Content-Length'),// 服务器类型,apache?lighttpd?"server" : xhr.getResponseHeader('Server'),"vary" : xhr.getResponseHeader('Vary'),"transferEncoding" : xhr.getResponseHeader('Transfer-Encoding'),// text/html ? text/xml?"contentType" : xhr.getResponseHeader('Content-Type'),"cacheControl" : xhr.getResponseHeader('Cache-Control'),// 生命周期?"exprires" : xhr.getResponseHeader('Exprires'),"lastModified" : xhr.getResponseHeader('Last-Modified')};// 在这里,做想做的事。。。}});
随时随地看视频慕课网APP

相关分类

JQuery
我要回答