OData从响应中获取标头值

时间:2012-04-25 09:04:15

标签: header response odata

我将OData与JQuery一起使用。我的问题是我需要检索Header,因为我需要Header值。你们知道语法吗?

我的代码如下:

      OData.request( {headers: { "X-CSRF-Token" :"Fetch" }, requestUri:queryserviceUriNew, user: uname, password: pword }, 
      function (data, response) 
     { 
        //Success Callback (received data is a Feed): 
   alert("Retrieved.");

   alert(response);
        // This is the object that hold the response, I need to capture the header value for "x-csrf-token"

      }

谢谢专家!

1 个答案:

答案 0 :(得分:1)

如果有其他人在寻找答案,语法为:

var header_value; // variable = variable_hold_httpResponse.headers ['header_item_that_you_want_to_get']; header_value = response.headers ['x-csrf-token'];

干杯!