title: redirect to servlet class file using jquery
body: <p>I have used jquery-1.11.2.min.js and chrome 40.0.2214.115</p>
  
  <p>In user registration form if anyone of the field is empty i want to show the alert message to user otherwise redirect to the servlet class file, in that servlet class i wrote the db connection for insert the user details.</p>
  
  <p>My user registration html code is</p>
  
  <pre><code>    &lt;script type="text/javascript" src="js/plugins/jquery-1.11.2.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function()
          {
      $("#submitid").click(function()
        {
          var fname=$("#firstname2").val();
          var lanme=$("#lastname2").val();
          var email=$("#email2").val();
          var mobileno=$("#mobileno").val();
          var username=$("#username").val();
          var pass=$("#password").val();
          if(fname==''||lname==''||email=''||mobileno==''||username==''||pass=='')
              {
              alert("Enter all fields");
              $("#userform").focus();
  
              }
          else
              window.location.href("Userdetailsins.java");
              });
          });&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form class="stdform stdform2" method="post"  id="userform"&gt;
  &lt;label&gt;First Name&lt;/label&gt;
   &lt;input type="text" name="userfname" id="firstname2" class="longinput" /&gt;
  &lt;label&gt;Last Name&lt;/label&gt;
  &lt;input type="text" name="userlname" id="lastname2" class="longinput" /&gt;
  &lt;label&gt;Email&lt;/label&gt;
  &lt;input type="text" name="mailid" id="email2" class="longinput" 
  &lt;label&gt;Mobile no&lt;/label&gt;
   &lt;input type="text" name="mobno" id="mobileno" class="longinput" 
   &lt;label&gt;User name &lt;/label&gt;
   &lt;input type="text" name="username" id="username" class="longinput" /&gt;
   &lt;label&gt;User Password &lt;/label&gt;
   &lt;input type="password" name="password" id="password" class="longinput" /&gt;&lt;/span&gt;                     
   &lt;input type="reset" value="Reset Button" /&gt;
   &lt;input type="submit"  id="submitid" name="submitid" value="Next"/&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>It doesn't show alert message when the fields are empty and doesn't redirect to another form. Even i tried with another html file to redirect it doesn't work. for redirection i have followed the guidelines shown below</p>
  
  <pre><code>//$(location).attr('href',"http://www.google.com");
          //window.open("next.html");
          //$("#submitform").focus();
  
           //$(window.location).attr('href', 'http://www.google.com');
  
          //window.navigator("next.html");
          //self.location="next.html";
  
      //top.location="next.html";
      //var url="www.google.com"
          //window.location.replace(url);
  
      //window.location.href("next.html");
      window.open("next.html");
  </code></pre>
  
  <p>The window.open() method works but i don't want to open as a separate window i just to redirect. Please anyone help to solve this.</p>
  
  <p>Thanks....</p>