0

Is it possible to read request header and thereafter fetch the variable value (say of example user id) in the jquery mobile + javascript code? If yes any example?

I found this article. How to get read data from response header in jquery/javascript, but not sure how it would work.

Community
  • 1
  • 1
Sheetal
  • 1,368
  • 1
  • 9
  • 15

3 Answers3

3

use this :

getAllResponseHeaders() 

more detail here

Or this:

getResponseHeader()

more detail here

Manish Kumar
  • 15,269
  • 5
  • 18
  • 27
1
 $.ajax({
 type: 'POST',
 url:'url', //the request url
 data: {}, //any param that you want to send in the request
 success: function(data){ //'data' is the response
    alert(request.getResponseHeader());
 }
 error: function () {
    alert("failed");
 }
 });
0

If you want request headers from this page you can get them via php getallheaders and display them as javascript array.

<script>
var headers = <?php echo json_encode(getallheaders()); ?>;
</script>
jcubic
  • 61,973
  • 54
  • 229
  • 402