title: How to send and retrieve data from web method using JQuery Ajax Call?
body: <p>I have a text box and a button next to it. I want to send the content of textbox through Jquery ajax call to webmethod and get back the upper case value of the same and display that in alert. So far i have this code but its not working.</p>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>function CallWM()
      {          
  
          var name = $('#name').val();         
  
  
          RealCallWM(name);
  
  
      }
      function RealCallWM(name) {
  
          $.ajax({
              url: 'Register.aspx/UpperWM',
              type: 'POST',
              contentType: 'application/json; charset=utf-8',
              data: { name: JSON.stringify(name) },
              success: OnSuccess(response),
              error: function (response) {
                  alert(response.responseText);
              }
          })
      };
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>  Name:    &lt;input id="name" type="text" /&gt; 
  &lt;input id="Button1" type="button" value="button" onclick="CallWM();"/&gt;&lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>WEB METHOD:</p>
  
  <pre><code> [WebMethod]
          public static string UpperWM(string name )
          {
              var msg=name.ToUpper();
              return (msg);
          }
  </code></pre>