title: How to get response message from AJAX data
body: <p>Here  I  write the response to ajax response object </p>
  
  <pre><code>protected void writeAjaxResponse(HttpServletRequest req 
                                   ,HttpServletResponse resp,String result){
          PrintWriter writer = null;
          try {
              writer = resp.getWriter();
          } catch (IOException e) {
              e.printStackTrace();
          }
          writer.println(result);
          return;
  
      } 
  </code></pre>
  
  <p>And later I called </p>
  
  <pre><code>writeAjaxResponse(req, resp, "&lt;p style=color:red&gt;Error occured recording
                                                             your feedback!&lt;/p&gt;");
  </code></pre>
  
  <p>In jquery </p>
  
  <pre><code>$.ajax({
                    type: 'POST',
                    url: 'savefeedback',
                    data: 'feedbacker='+feedbacker+'feedbackeremail=
                     '+feedbackeremail+'feedbacker='+feedbackermsg,
                    success:function(data){
                     alert(data); //here is the pin point
  
  
                      }
                  });
  </code></pre>
  
  <p>But in alert I am getting </p>
  
  <pre><code>    [object XMLDocument]
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is my servlet <code>doPost()</code> method</p>
  
  <pre><code>@Override
      protected void doPost(HttpServletRequest req, HttpServletResponse resp)
              throws ServletException, IOException { 
  
           String feedbacker = req.getParameter("feedbacker");
           String  feedbackeremail = req.getParameter("feedbackeremail");
           String  feedbackermsg = req.getParameter("feedbackermsg");
  
          boolean saveFeedback = MailSenderServlet.
              saveFeedback(req, resp, feedbackeremail, "",
                    feedbackermsg, feedbacker, feedbackeremail);
          if(saveFeedback){
              writeAjaxResponse(req, resp, "Feedback received succesfully!");
          }else{
              writeAjaxResponse(req, resp, "Error occured  !");
          }
  
      } 
  </code></pre>
  
  <p>But i am expecting my response message.</p>
  
  <p>Please let me know if I missed something.</p>
  
  <p>Please help!!!!</p>