title: PageMethod not found when using JQuery
body: <p>well, i'm trying to retrieve info from a PageMethod using jquery and ajax, and so far i handn't had any luck</p>
  
  <p>While debuging the whole thing, i found that my error part was launching, then i used the debugger of VS and didnt got any info, but with Firebug i found out the method wasn't being found, given a Internal Server Error was thrown</p>
  
  <p>Here's my aspx code</p>
  
  <pre><code>&lt;%@ Page Language="vb" AutoEventWireup="false" CodeBehind="RutaLecturista.aspx.vb" Inherits="LocalLecturas.RutaLecturista" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Ruta Lecturista&lt;/title&gt;
      &lt;link type="text/css" href="../Estilo.css" /&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" language="javascript"&gt;
          var map; 
          var trazoRuta = new Array();
  
          $(document).ready(function()
          {
              inicializar();
          });
  
          function inicializar()
          {
              var latlng = new google.maps.LatLng(29.082807, -110.928197);
              var myOptions = 
              {
                  zoom: 12,
                  center: latlng,
                  mapTypeId: google.maps.MapTypeId.ROADMAP
              };
              map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
              extraerDatos();
          }
  
          function extraerDatos()
          {
              $.ajax({
                  type: 'POST',
                  url: 'RutaLecturista.aspx/obtenerCoordenadas',
                  data: '{}',
                  contentType : "application/json; charset=utf-8",
                  dataType: 'json',
                  succes: function(xml)
                  {
                      crearMarca(xml);
                  },
                  error: function(XMLHttpRequest, textStatus, errorThrown)
                  {
                      alert('Error al consultar el servicioWeb: ' + errorThrown + ' ' + textStatus + ' ' + XMLHttpRequest);
                      $("#errmsg").ajaxError(function(event, request, settings)
                      {
                          $(this).append("&lt;li&gt;Error al extraer los datos " + settings.url + "&lt;/li&gt;");
                      });
                  }
              });
          }
  
          function crearMarca(xml)
          {
              try
              {
                  alert('Datos obtenidos!!!');
                  $(xml).find('Table').each(function()
                  {
                      var lat = $(this).find('Latitud').text();
                      var lon = $(this).find('Longitud').text();
                      var certeza = $(this).find('Precision').text();
                      var titulo = $(this).find('F_Actual').text();
                      var location = new google.maps.LatLng(lat, lon);
                      trazoRuta.push(location);
                      var marker = new google.maps.Marker(
                      {
                          position: location, 
                          map: map
                      });
                      marker.setTitle(titulo);
                      var circuloCerteza;
                      google.maps.event.addListener(marker, 'mouseover', function() 
                      {
                          var populationOptions = 
                          {
                              strokeColor: "#FF0000",
                              strokeOpacity: 0.8,
                              strokeWeight: 2,
                              fillColor: "#FF0000",
                              fillOpacity: 0.35,
                              map: map,
                              center: location,
                              radius: certeza / 2
                          };
                          circuloCerteza = new google.maps.Circle(populationOptions);
                      });            
                      google.maps.event.addListener(marker, 'mouseout', function() 
                      {
                          circuloCerteza.setMap(null)
                      });
                  });
                  trazoRuta.reverse();
                  var ruta = new google.maps.Polyline(
                  {
                      path: trazoRuta,
                      strokeColor: "#FF0000",
                      strokeOpacity: 1.0,
                      strokeWeight: 2
                  });
                  ruta.setMap(map);                
              }
              catch(err)
              {
              }
          }
  
          function getQueryVariable(variable)
          {
              var query = window.location.search.substring(1);
              var vars = query.split("&amp;");
              for (var i=0;i&lt;vars.length;i++)
              {
                  var pair = vars[i].split("=");
                  if (pair[0] == variable)
                  {
                      return pair[1];
                  }
                  else
                  {
                      return "";
                  }
              }
          }
  
          /*function crearMarca(titulo, lat, lon, certeza)
          {
              var location = new google.maps.LatLng(lat, lon);
              var marker = new google.maps.Marker(
              {
                  position: location, 
                  map: map
              });
              marker.setTitle(titulo);
              var circuloCerteza;
              google.maps.event.addListener(marker, 'mouseover', function() 
              {
                  var populationOptions = 
                  {
                      strokeColor: "#FF0000",
                      strokeOpacity: 0.8,
                      strokeWeight: 2,
                      fillColor: "#FF0000",
                      fillOpacity: 0.35,
                      map: map,
                      center: location,
                      radius: certeza / 2
                  };
                  circuloCerteza = new google.maps.Circle(populationOptions);
              });            
              google.maps.event.addListener(marker, 'mouseout', function() 
              {
                  circuloCerteza.setMap(null)
              });
          }    //*/      
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="map_canvas" style="width:50%; height:50%"&gt;&lt;/div&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;div id="errmsg" style="width: 244px"&gt;
          &lt;asp:Label ID="Label_1" runat="server"&gt;No hay Coordendas para esta Ruta&lt;/asp:Label&gt;
          &lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"&gt;
          &lt;/asp:ScriptManager&gt;
  &lt;%--        &lt;asp:GridView ID="gvCoordenadas" runat="server" AutoGenerateColumns="False" CellPadding="4" 
                  GridLines="None" CssClass="REPORTE"&gt;
                  &lt;FooterStyle CssClass="REPORTE_FooterStyle" /&gt;
                  &lt;RowStyle CssClass="REPORTE_RowStyle " /&gt;  
              &lt;Columns&gt;
                  &lt;asp:BoundField DataField="Latitud" HeaderText="Latitud" /&gt;
                  &lt;asp:BoundField DataField="Longitud" HeaderText="Longitud" /&gt;
                  &lt;asp:BoundField DataField="F_ACTUAL" HeaderText="Fecha" /&gt;
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;
  --%&gt;    
          &lt;/div&gt;    
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here's the codeBehind code</p>
  
  <pre><code>Partial Public Class RutaLecturista
      Inherits System.Web.UI.Page
  
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          'If Session("USR") = Nothing Then
          '    Response.Redirect("../Acceso.aspx?dato=No tiene acceso en este sistema")
          'End If
          Response.Write("&lt;script type=""text/javascript"" src=""http://maps.google.com/maps/api/js?sensor=false""&gt; &lt;/script&gt;")
          'Dim sb As New System.Text.StringBuilder()
          'sb.Append("&lt;script language=""javascript"" type=""text/javascript""&gt;")
          'Try
          '    Dim id_lec As String = Request.QueryString("id_lec").Substring(0, 10)
          '    Proceso.Fill_DataSet(DataSet, Consultas.obtenerLocalizacion(id_lec, "", "", ""), "Coordenadas" + id_lec)
          '    If DataSet.Tables("Coordenadas" + id_lec).Rows.Count &gt; 0 Then
          '        Label_1.Visible = False
          '        gvCoordenadas.DataSource = DataSet.Tables("Coordenadas" + id_lec)
          '        gvCoordenadas.DataBind()
          '        gvCoordenadas.Visible = True
          '        sb.Append("function crearMarcas(){" + vbNewLine)
          '        For Each linea As Data.DataRow In DataSet.Tables("Coordenadas" + id_lec).Rows
          '            sb.Append("crearMarca(""" + linea("F_Actual").ToString + """, " + linea("Latitud").ToString + ", " + linea("Longitud").ToString + ", " + linea("precision").ToString + ");" + vbNewLine)
          '        Next
          '        sb.Append("}" + vbNewLine)
          '        sb.Append("var trazoRuta = [" + vbNewLine)
          '        For contador As Integer = 0 To DataSet.Tables("Coordenadas" + id_lec).Rows.Count - 1
          '            sb.Append("new google.maps.LatLng(" + DataSet.Tables("Coordenadas" + id_lec).Rows(contador).Item("Latitud").ToString + ", " + DataSet.Tables("Coordenadas" + id_lec).Rows(contador).Item("Longitud").ToString + ")")
          '            If contador + 1 &lt; DataSet.Tables("Coordenadas" + id_lec).Rows.Count Then
          '                sb.Append("," + vbNewLine)
          '            End If
          '        Next
          '        sb.Append("];" + vbNewLine)
          '    Else
  
          '    End If
          'Catch ex As Exception
          'End Try
          'sb.Append("&lt;/script&gt;")
          'ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ajax", sb.ToString(), False)
      End Sub
  
      &lt;System.Web.Services.WebMethod()&gt; _
      Public Function obtenerCoordenadas() As String
          Dim datos As New Data.DataSet
          Dim resultado As String = ""
          Dim id_lec As String = Request.QueryString("id_lec").Substring(0, 10)
          Proceso.Fill_DataSet(datos, Consultas.obtenerLocalizacion(id_lec, "", "", ""), "Coordenadas" + id_lec)
          If DataSet.Tables("Coordenadas" + id_lec).Rows.Count &gt; 0 Then
              resultado = datos.GetXml
          End If
          Return resultado
      End Function
  
  End Class
  </code></pre>
  
  <p>Hope i can get a answer quick, i'm running out of time, patience and ideas :S</p>