title: How to pass authorization header in $.post() method using Javascript?
body: <p>I want to pass Authorization header while POSTing data to server.
  I tried </p>
  
  <pre><code>$.ajax({
     url : &lt;ServiceURL&gt;,
     data : JSON.stringify(JSonData),
     type : 'POST',
     contentType : "text/html",
     dataType : 'json',
     success : function(Result) {
     },
     beforeSend: function (xhr) {
        xhr.setRequestHeader('Authorization', &lt;Authorization Header Value&gt;);
     },
     error: function (RcvData, error) {
        console.log(RcvData);
     }
  });
  </code></pre>
  
  <p>But REST service returns error (error code : 500). The same service was working fine with $.post() before adding authorization.
  could anyone tell me "How to pass authorization header in $.post()??"</p>