title: Dotnetnuke WebService with jquery Post
body: <p>I am developing a dotnetnuke module and have lots of issues connecting to a webservice through javascript to retrieve data.</p>
  
  <p>I have the folloiwng javascript:</p>
  
  <pre><code>function Test() {
          $.ajax({
              type: "POST",
              url: 'http://localhost/DNN11/service1.asmx/TestMethod',
              data: "{'data':'" + "abc" + "'}",
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(msg) {
                  alert("success");
              },
              error: function(e) {
                  alert("error");
              }
          });
  
  
      }
  </code></pre>
  
  <p>Then the following WebMethod in my webservice</p>
  
  <pre><code>[WebMethod]
      public string TestMethod(String data)
      {
          return "Hello World";
      }
  </code></pre>
  
  <p>However when the post is not being called successfully, I am not able to get through my webservice. It keeps giving me a 500 Internal Server error page.</p>
  
  <p>What could be wrong please? Is there any other way I need to go about this?</p>
  
  <p>Thanks</p>
  
  <p>[Edit]</p>
  
  <p>This is the entire code</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function Test() {
  
          $.ajax({
              type: "POST",
              url: '&lt;%=ResolveUrl("~/DesktopModules/ModuleTest/WebService1.asmx/TestMethod")%&gt;',
              data: '{ data: "test" }',
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function(msg) {
                  alert("Success: " + msg);
              },
              error: function(msg) {
                  alert("Failed: " + msg.status + ": " + msg.statusText);
              }
          });   
  
      }
  &lt;/script&gt;
  
  &lt;div&gt;
      &lt;input type="button" value="Load" onclick="Test(); return false;" /&gt;
  &lt;/div&gt;
  
  [System.Web.Script.Services.ScriptService]
      public class WebService1 : System.Web.Services.WebService
      {
  
          [WebMethod]
          [ScriptMethod()]
          public string TestMethod(string data)
          {
              return "Hello World";
          }
      }
  </code></pre>
  
  <p>I have tried putting the Webservice in the DotNetNuke folder in a new folder and both in the local project.. I also put the ScriptMethod() Tag in the WebService which allows scripts to call it.. but still nothing</p>