title: ASP.net Ajax Unknown Web method
body: <p>So, I have done this before and made many many ajax calls 
  For some reason <strong><em>this</em></strong> one doesn't work =(</p>
  
  <p><strong>What do I need to change to get this one to work?</strong></p>
  
  <p>Previously I had an internal server error 500, but after pasting some working code and renaming methods to shorter names finally it changed over to this error of Unknown web method.</p>
  
  <h2>Setup</h2>
  
  <p>I am using jQuery to make Ajax calls to WebMethods in my Codebehind for my ASP.NET page.</p>
  
  <p>Here is my C# WebMethod</p>
  
  <pre><code>    [WebMethod(EnableSession = true)]
      [ScriptMethod]
      public string viewApps(string foo)
      {
          string x = "";
  
          //130 lines of useful code.
  
          x = "0";
          return x;
      }
  </code></pre>
  
  <p>Here is the Javascript/jQuery doing the ajax call. It is in side a   with all my other ajax calls. The other ones work. This one does not. It triggered by an onclick event in the html.</p>
  
  <pre><code>        function viewApps() {
  
              var food = "hamburger";
              $.ajax(
              {
                  //send selected makes
                  type: "POST",
                  url: "MassUpdater.aspx/viewApps",
                  dataType: "json",
                  data: "{foo:" + food + "}",
                  contentType: "application/json; charset=utf-8",
  
                  //process the response
                  //and populate the list
                  success: function (msg) {
  
                      //just for show
                  },
                  error: function (e) {
  
                      alert(JSON.stringify(e));
                      $('#result').innerHTML = "unavailable";
                  }
              });
  
  //to be uncommented later when functionality works.
  
              // populateBrakeConfigs();
              //  populateBedConfigs();
              //   populateBodyStyleConfigs();
              //   populateSpringConfigs();
              //   populateSteeringConfigs();
              //  populateWheeleBase();
              //   populateTransmission();
              //   populateDriveTypes();
  
              function populateBrakeConfigs() { }
              function populateBedConfigs() { }
              function populateBodyStyleConfigs() { }
              function populateSpringConfigs() { }
              function populateSteeringConfigs() { }
              function populateWheeleBase() { }
              function populateTransmission() { }
              function populateDriveTypes() { }
  
          }
  </code></pre>
  
  <p>The ajax error looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/ocSKo.png" alt="Ajax error"></p>
  
  <p>I am also willing to provide any additional code or information about my project upon request.</p>