title: How to send parameter from JSP to servlet using Ajax call?
body: <p>I need to send a parameter to a servlet through an ajax call i am trying with this code but it is not working.I am posting my code and the way i catch it to the Servlet...</p>
  
  <pre><code> function loadJson() {
     $.ajax({
       url: "JsonServlet",
       type: "post",
       dataType: "json",
       data: {
         "value": "2"
       },
       error: function () {
         alert("error occured!!!");
       },
       success: function (data) {
         alert(data.value);
       }
     });
   }
  </code></pre>
  
  <p>and here is  where i am calling the function </p>
  
  <pre><code>&lt;form enctype="application/json" method="post"&gt;
    &lt;input type="submit" value="submit" onclick="loadJson()" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and in servlet i am using String <code>value=request.getParameter("value");</code></p>
  
  <p>i am using   <code>&lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt;</code> jQuery file somebody please help</p>