title: Facing AJAX issue with JSP
body: <p>I am working on a small tool which just consists of a single JSP which is used for view as well as for processing the AJAX response.</p>
  
  <p>If the call is of type 'GET', I am showing a form the user.</p>
  
  <pre><code>&lt;form id="submitForm" method="post"&gt;
  &lt;div class="ui-widget"&gt;
  &lt;label for="tags"&gt;Please Select the Merchant : &lt;/label&gt;
  &lt;input id="tags" name="mechant" style="width:300px;height:40px;border: 0.5px solid;border-radius: 5px;"&gt;&amp;nbsp;&amp;nbsp;
  &lt;input type="submit" value="Get Data" style="border: 0.5px solid;border-radius: 5px;"&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And following is the code which will make the call.</p>
  
  <pre><code>$("#submitForm").submit(function() {
      $.ajax({
      url: 'serve_tx_2.jsp',
      type: 'POST',
      data: {q: $('#tags').val()},
      success: function(data) {
          $('#data').html(data);
          alert('Load was performed.');
      },
      beforeSend: function() {
         // $('.loadgif').show();
      },
      complete: function() {
         // $('.loadgif').hide();
      }
  });
          //return false;
  });
  </code></pre>
  
  <p>Once the user submits the form which goes as 'POST' the logic in the same JSP is returning the response.</p>
  
  <p>Right now I am trying with a very simple logic.</p>
  
  <pre><code>response.setContentType("text/plain");  
  response.setCharacterEncoding("UTF-8"); 
  response.getWriter().write("Hello World");
  </code></pre>
  
  <p>Now when this response is return the whole of initial page is washed off and I just see "Hello World" on the page. Even though as per my understanding only the div with id "data" should be updated with value.</p>
  
  <p>Kindly anyone have a look and let me know what might be going wrong here.
  Thanks in advance.</p>