title: Jquery: Ajax call to servlet & get data as json
body: <p>I'm newbie on servlet and I need to get data from database to display chart   </p>
  
  <pre><code> $.ajax({
       url : "NameServlet",
       dataType : 'json',
       error : function(){
          alert("Error Occured");
       },
       success : function(data) {
          var receivedData = [];
      //how to put data in var (i.e. receivedData) which is received from servlet
       }
      });
  </code></pre>
  
  <p>what would be my <strong>servlet</strong> to get data </p>