title: jQuery: Ajax call to asp.net webservice fails, server return 500 error
body: <p>Ok, so I created a test project just to verify that jQuery AJAX works with asp.net service, and it does no problems.  I used a default HelloWorld service created in VS studio. I am calling the service via jQuery like this:</p>
  
  <p>in Default.aspx:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      $(document).ready(function() {
  
          //test web service
          $.ajax({
              type: "POST",
              contentType: "application/json; charset=utf-8",
              url: "TestService.asmx/HelloWorld",
              data: "{}",
              dataType: "json",
              success: function(msg) { alert(msg);},
              error: function (XMLHttpRequest, textStatus, errorThrown) {
                  debugger;
              }
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>in TestService.asmx</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Services;
  
  namespace WebServiceTestWitJQuery
  {
      /// &lt;summary&gt;
      /// Summary description for TestService
      /// &lt;/summary&gt;
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [System.ComponentModel.ToolboxItem(false)]
      // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
      [System.Web.Script.Services.ScriptService]
      public class TestService : System.Web.Services.WebService
      {
  
          [WebMethod]
          public string HelloWorld()
          {
              return "Hello World";
          }
      }
  }
  </code></pre>
  
  <p>I then proceeded and copied everything exactly as it is in my project and it does not work. I get a 500 server error. </p>
  
  <p>I verified following:</p>
  
  <ol>
  <li>web.configs identical</li>
  <li>pages identical</li>
  <li>service class identical</li>
  <li>jquery ajax call identical</li>
  <li>I can navigate to <a href="http://localhost:3272/TestService.asmx?op=HelloWorld" rel="nofollow noreferrer">http://localhost:3272/TestService.asmx?op=HelloWorld</a> and webservice works fine.</li>
  </ol>
  
  <p>What else?</p>