How to get Response Header location from jQuery Get?

ajax, javascript, jquery, response

Solution

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'));
    }
});

Problem

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 return null. Here's my current code ``` $(document).ready(function(){ var geturl; geturl = $.ajax({ type: "GET", url: 'http://searchlight.cluen.com/E5/Login.aspx?URLKey=uzr7ncj8)', }); var locationResponse = geturl.getResponseHeader('Location'); console.log(locationResponse); }); ```

Original source

Related problems