title: Trying to call a WebMethod that resides on an .aspx page using jQuery
body: <p>I’m trying to call a WebMethod that resides on an .aspx page using jQuery.  In the development environment (localhost) works fine, but when I run it from the server it seems like the WebMethod is not called at all.  The server environment tools I’m using are .Net 2.0 SP2, IIS7.5, and Visual Studio 2005.</p>
  
  <p>The WebMethod that is being called creates and writes an .xml file.  This file is then searched by another method that doesn’t find it since the WebMethod is not executed and the file was never created.  </p>
  
  <p>These are some of the things I’ve tried in order to fix the problem:</p>
  
  <p>•   Add a ScriptManager.  I deleted it from the .aspx file since it didn’t fix the problem and read in a blog that a ScriptManager wasn’t needed in order to make the WebMethod call works.</p>
  
  <p>•   Set the property EnablePageMethods = true in the RadScriptManager.  Currently it’s not set to true anymore since it didn’t fix the problem.</p>
  
  <p>•   Add a ScriptModule  in the web.config file.  </p>
  
  <p>•   Add the the Protocols  in the web.config:</p>
  
  <pre><code>  &lt;system.web&gt;
       &lt;webServices&gt;
          &lt;protocols&gt;
             &lt;add name="HttpSoap"/&gt;
             &lt;add name="HttpPost"/&gt;
             &lt;add name="HttpGet"/&gt;
              &lt;add name="Documentation"/&gt;
          &lt;/protocols&gt;
       &lt;/webServices&gt;
     &lt;system.web&gt;
  </code></pre>
  
  <p>I deleted these from the Web.config file since they didn’t fix the problem and read in a blog that these tags were needed in environments running with .net 1.1 and IIS 5.0, IIS 5.1, IIS6.0.</p>
  
  <p>•    Assign write permissions to users and pools in order for them to be able to write to the folder. (IIS 7.5)</p>
  
  <p>Am I missing something in the Web.config file?  What could be causing the problem?</p>
  
  <p>Here is the WebMethod:</p>
  
  <pre><code>[WebMethod]
  public static string GetContinuityofCareDocument(string continuityofCareDocument, string    indicator, string endOffile)
  {
      string _filePrefix = indicator;
      string _fileNamexml = @"C:\TempFile" + _filePrefix + ".xml";
      StreamWriter _txtFile = new StreamWriter(_fileNamexml, true);
      _txtFile.Write(continuityofCareDocument);
      _txtFile.Close();
  
          return " Success";
  }
  </code></pre>
  
  <p>Here is the where the WebMethod is being called from:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  
  
  function SendCcdtoServer(params,indicator,endOffile) {
      jQuery.ajaxSetup({ async: true });
      jQuery.ajax({
      type: "POST",
          url: '&lt;%=ResolveUrl("WebServiceDisplayCCD.aspx")%&gt;'+'/GetContinuityofCareDocument',
          data:  '{continuityofCareDocument: "'+params+'", indicator: "'+indicator+'", endOffile:             "'+endOffile+'"}',
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: OnSuccess,
          error: function(response) {
              alert("response + failure  ");
          }
      });
  }
  function OnSuccess(response) {
      alert("Success");
  }
  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is the Web.config:</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;configSections&gt;
          &lt;sectionGroup name="Localization"&gt;
              &lt;section name="Localization"                        type="Localization.LocalizationConfigurationHandler, Localization,Version=1.0.0.0,  Culture=neutral, PublicKeyToken=CA5930580A5E0032" /&gt;
          &lt;/sectionGroup&gt;
      &lt;/configSections&gt;
  
  
      &lt;system.web&gt;
  
          &lt;pages enableViewStateMac="false" validateRequest="true"                            enableEventValidation="false"   viewStateEncryptionMode="Never"                     smartNavigation="false" /&gt;
          &lt;httpModules&gt;
              &lt;remove name="ScriptModule" /&gt;
              &lt;add name="ScriptModule" type="System.Web.Handlers.ScriptModule,                        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,                    PublicKeyToken=31bf3856ad364e35" /&gt;
          &lt;/httpModules&gt;
          &lt;httpHandlers&gt;
              &lt;add path="Telerik.Web.UI.WebResource.axd"                                  type="Telerik.Web.UI.WebResource" verb="*" validate="false" /&gt;
          &lt;/httpHandlers&gt;
          &lt;compilation debug="true"&gt;
              &lt;assemblies&gt;
                  …
              &lt;/assemblies&gt;
          &lt;/compilation&gt;
          &lt;sessionState mode="SQLServer" sqlConnectionString="Data                            Source=###.###.###.#;User ID=XXXXX;password=XXXXXX"                             cookieless="false" timeout="60" /&gt;
          &lt;globalization enableClientBasedCulture="true" /&gt;
  
      &lt;/system.web&gt;
  
  
      &lt;location allowOverride="true" inheritInChildApplications="true"&gt;
          &lt;appSettings&gt;
              &lt;add key="Authentication" value="Windows" /&gt;
          &lt;/appSettings&gt;
      &lt;/location&gt;
  
      &lt;system.webServer&gt;
          &lt;validation validateIntegratedModeConfiguration="false" /&gt;
          &lt;handlers&gt;
              &lt;add name="Telerik_Web_UI_WebResource_axd" verb="*"                                 preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd"                 type="Telerik.Web.UI.WebResource"/&gt;
          &lt;/handlers&gt;
      &lt;/system.webServer&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>When using chrome's developer tools I get a 500 error, which states "Invalid JSON" and contains the script of the whole page.</strong></p>
  
  <p>After searching for possible solutions to this error I get many blogs about how to solve an "Invalid JSON primitive" error, which doesn't seem to apply to the problem I'm dealing with.</p>
  
  <p>What could be causing this?</p>