title: NTLM implementation in JavaScript with POST method
body: <p>I searched a lot but did not find suitable answer to implement my project code using NTLM in JavaScript. I want to send POST method with dataType as json type but every time I am getting 401 - Unauthorized message.</p>
  
  <p>I referred the link <a href="https://github.com/erlandranvinge/ntlm.js/tree/master" rel="nofollow noreferrer">https://github.com/erlandranvinge/ntlm.js/tree/master</a> to download ntlm.js and implemented as described but no success.</p>
  
  <p>Please help if anybody knows about it. </p>
  
  <p>The provided ntlm code is below:</p>
  
  <pre><code>Ntlm.setCredentials('domain', 'username', 'password');
  var url = 'http://myserver.com/secret.txt';
  
  if (Ntlm.authenticate(url)) {
      performPostOperation();
      // =&gt; My super secret message stored on server.
  }
  </code></pre>
  
  <p>Inside the <code>performPostOperation()</code> function:</p>
  
  <pre><code>$.ajax({
      "method" : 'POST',
      "url" : URL,
      "data": {data}
      "dataType":"json",
      "withCredentials":true,
      credentials:"include",
      beforeSend:function(xhr){
          xhr.setRequestHeader('Content-Type', 'application/json');
          xhr.setRequestHeader('domain', 'DOMAINNAME');
          xhr.setRequestHeader('username', username);
          xhr.setRequestHeader('password', password);
          xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
          xhr.setRequestHeader('Accept', 'application/json');
      }
  })
  </code></pre>
  
  <p>Is there anything that I am missing?</p>