title: Ajax post method not called
body: <p>Ajax is not calling the servlet</p>
  
  <p>My web.xml:</p>
  
  <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;LoginServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;com.web.LoginServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt; 
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;LoginServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/LoginServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>The script:</p>
  
  <pre><code>//function to check name and comment field 
  function checkCommentsForm(){
      if(userName.attr("value") &amp;&amp; userPass.attr("value"))
      {
          alert("true returned");
          return true;
      }
      else
      {
          alert("fasle returned");
          return false;  
      }
  }
  //When form submitted
  $("#formL").submit(function(){
      if(checkCommentsForm()){
          $.ajax({
              type:"POST",
              url:"/LoginServlet/",
              data:"user="+userName.val()+"&amp;pass="+userPass.val(),
              success: function(msg) {$('#targetDiv').hide();$("#targetDiv").html ("&lt;h3&gt;" + msg + "&lt;/h3&gt;").fadeIn("slow");
              }
          });
          alert('ppppppppppppppppp----------');
      }
      else 
          alert("Please fill UserName &amp; Password!");
      return false;
      });
  });
  </code></pre>
  
  <p>The FORM:</p>
  
  <pre><code>&lt;div&gt;
      &lt;form id="formL" name="formL" method="post" onsubmit="return false;"&gt;
          &lt;span class="style3"&gt;&lt;strong&gt;Enter Username &amp;amp;
              Password to Login : &lt;/strong&gt;&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span class="style1"&gt;Username :&amp;nbsp;&lt;/span&gt;&amp;nbsp;
              &lt;input name="user" id="user" type="text"&gt; &lt;br&gt;
              &lt;span class="style1"&gt;Password :&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;input name="pass" id="pass" type="password"&gt; &lt;br&gt;
              &lt;input name="button" id="button" value="Submit" type="submit"&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;div id="targetDiv" style="display: none;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The alerts are coming as follows:</p>
  
  <pre><code>**The servlet are working but through ajax it was not called any clue what happen ?**
  </code></pre>