title: Call Ajax from MasterPage with WebService
body: <p>I'm trying call by Ajax a method from a masterpage without success:</p>
  
  <p>MasterPage</p>
  
  <pre><code>$(function ListaCategorias() {
          var pageUrl = '&lt;%=ResolveUrl("~/WebService/MenuEsquerdo.asmx")%&gt;';
  
          $.ajax({
              type: "POST",
              url: pageUrl + '/ListaCategoriasMenu',
              data: "{}",
              contentType: "application/json; charset=utf-8",
              dataTyle: "json",
              async: false,
              error: function (jqXhR, textStatus, errorThrown) { alert(errorThrown); },
              success: function (data) {
                  var Categorias = data.d;
                  var counter = 0;
  
                  aCategorias = [];
  
                  //Carrega as Categorias
                  $.each(Categorias, function (index, categorias) {
                      aCategorias[counter] = [
                          categorias.cat_id, categorias.cat_descricao, categorias.cat_total_anuncios
                      ];
                      counter++;
                  });
              }
          });
      });
  </code></pre>
  
  <p>MenuEsquerdo.asmx</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Summary description for MenuEsquerdo
  /// &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 MenuEsquerdo : System.Web.Services.WebService
  {
  
      [WebMethod]
      //[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public static IList ListaCategoriasMenu()
      {
          tab_categorias tabCategorias = new tab_categorias { cat_ativo = true, cat_deletado = false };
          var listCategorias = tabCategorias.ListaCategoriasMenu();
  
          return listCategorias;
      }
  }
  </code></pre>
  
  <p>I just get the error message "Internal Server Error".</p>
  
  <p>What am I doing wrong?</p>
  
  <p>I want to load a menu I thought in use a WebService but if you know a better option like event handler I'm open minded.</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I also tryied to use a User Control, but the error message returned is Forbbiden!</p>