How to get Response Header location from jQuery Get?

前端 未结 3 1163
猫巷女王i
猫巷女王i 2020-12-31 05:21

So I am trying to get the location from a header response via jQuery get. I tried using getResponseHeader(\'Location\') and getAllResponseHeaders() but they both seem to ret

3条回答
  •  再見小時候
    2020-12-31 05:39

    The headers will be available when the asynchronous request returns, so you will need to read them in the success callback:

    $.ajax({
        type: "GET",
        url: 'http://searchlight.cluen.com/E5/Login.aspx?URLKey=uzr7ncj8)',
        success: function(data, status, xhr) {
            console.log(xhr.getResponseHeader('Location'));
        }
    });
    

提交回复
热议问题