title: Sending data/object to ajax
body: <p>How could I send data to a ajax call, after converting an object to <code>json</code>?</p>
  
  <pre><code>@Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
     response.setContentType("text/plain");
     PrintWriter writer = response.getWriter();
     LinkedList list = new LinkedList();
     list.add("first");
     list.add("second");
     list.add("third");
     Gson gson = new Gson();
     gson.toJson(list);
     writer.println("From servlet");
  }
  </code></pre>
  
  <p>Ajax:</p>
  
  <pre><code>$.ajax( {
                      url : 'http://localhost:8081/Football/SendToAjax',
                      type : 'GET'
                  })
                  .done(function(message) {
                      alert(message);
                  }).
                  fail(function(message) {
                      alert(message);
                  });
  </code></pre>