title: Form Based Authentication using Javascript for Sharepoint
body: <p>I am trying to create a web page using javscript that uses form based authentication to login to the sharepoint server but it keeps using NTLM which is windows based authentication. Is there anyway to allow form based authentication using javascript as this web page is for mobile and phonegap? Thanks in advance. Any help appreciated.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;script src="jquery-1.6.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div&gt;
  &lt;script type="text/javascript"&gt;
  
  $(document).ready(function () {
  var soapEnv = "&lt;soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'&gt; \
    &lt;soap:Body&gt; \
      &lt;Login xmlns='http://schemas.microsoft.com/sharepoint/soap/'&gt; \
        &lt;username&gt;username1&lt;/username&gt; \
        &lt;password&gt;password&lt;/password&gt; \
      &lt;/Login&gt; \
    &lt;/soap:Body&gt; \
  &lt;/soap:Envelope&gt;"
  
  // Call web service
  $.ajax({
  url: "http://servername:serverport/_vti_bin/authentication.asmx",
  type: "POST",
  dataType: "xml",
  data: soapEnv,
  complete: processListAccessResult,
  contentType: "text/xml; charset=\"utf-8\""
  });
  });
  
  // Process result
  function processListAccessResult(xData, status) {
  alert(xData);
  alert(status);
  }
  
  &lt;/script&gt;
  
  &lt;ul id="data"&gt;&lt;/ul&gt; 
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>