title: Problem in getting response from server in jquery
body: <p>I'm using <code>$.ajax(options)</code> method to pass the request to server based on username and password, but whenever I try to print the response by XMLHttpRequest object when response gets successful, I'm getting an empty value.</p>
  
  <pre><code>$(document).ready(function(){
  $("#form").submit(function(){
  $.ajax({url:"Chat.jsp",type:"POST",data:$("#form").serialize(),success:function(request) {
  
    alert(request.responseText); //This is displaying nothing
   },error:function(){document.write("YOU can't");}});
  
  });
  });
  </code></pre>
  
  <p>This is what I'm doing in my servlets code after executing query:</p>
  
  <pre><code>try {
      String user = request.getParameter("j_username");
      String password = request.getParameter("j_password");
      if(user != null &amp;&amp; password != null) {
           String query = "Select * from users where user_name="+"\'"+user+"\'"+"&amp;&amp; user_pass="+"\""+password+"\"";
           DBCheck db= new DBCheck();
           boolean b = db.doExecuteQuery(con.createStatement(),query);
           response.setHeader("Cache-Control", "no-cache");
           if(b) {
  
          response.getWriter().println("Username already exits");      
           }
           else {
          response.getWriter().println("Username doesn't exit");
           }  
      }
       }  
       catch(SQLException ex) {
          ex.printStackTrace();
       }
     }
  </code></pre>
  
  <p>May I know the problem, and how can I fix it?</p>