title: Calling servlet function upon button click
body: <p>My html page has</p>
  
  <pre><code>&lt;div id="dialog" title="Items"&gt;
  &lt;div id="username"&gt;
  &lt;h4&gt;Welcome &lt;i&gt;&lt;%=(String) session.getAttribute("username")%&gt;&lt;/i&gt;&lt;/h4&gt;
  &lt;/div&gt;
  &lt;div id="disconnect"&gt;
  &lt;button&gt;LogOut&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>$("#disconnect").click(function(){</p>
  
  <pre><code> $.ajax({
          type: "POST",
          url: "XXXservlet",
          success: function(data) {
               window.location.replace("index,html");}
  </code></pre>
  
  <p>}):</p>
  
  <p>Now upon click on the log out button I want to call disconnect function in my servlet.Merely redirecting to a new page wont help.I want it the user to log out of application..How do I achieve with jquery?? </p>
  
  <p>Note:I am using doPost in servlet</p>
  
  <p>Sorry if it is a simple question.I am begineer to programming</p>
  
  <p>Thanks........</p>