title: Calling ASP.NET web service function via GET method with jQuery
body: <p>I'm trying to call web service function via GET method using jQuery, but having a problem. This is a web service code:</p>
  
  <pre><code>[WebService(Namespace = "http://something.com/samples")]
  [ScriptService]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  public class TestWebService  : System.Web.Services.WebService {
      [WebMethod]
      public string Test2()
      {
          string result = null;
  
      try
          {
              result = "{'result':'success', 'datetime':'" + DateTime.Now.ToString() + "'";
          }
          catch (Exception ex)
          {
              result = "Something wrong happened";
          }
  
          return result;
      }
  
  }
  </code></pre>
  
  <p>That's the way I call the function:</p>
  
  <pre><code>$.ajax({ type: "GET",
           url: "http://localhost/testwebsite/TestWebService.asmx/Test2",
           data: "{}",
           contentType: "application/json",
           dataType: "json",
           error: function (xhr, status, error) {
               alert(xhr.responseText);
           },
           success: function (msg) {
               alert('Call was successful!');
           }
       });
  </code></pre>
  
  <p>Method is called successfully, but result string gets covered by XML tags, like this:</p>
  
  <pre><code>&lt;string&gt;
  {'result':'success', 'datetime':'4/26/2010 12:11:18 PM'
  &lt;/string&gt;
  </code></pre>
  
  <p>And I get an error because of this (error handler is called). Does anybody know what can be done about this? </p>