Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/09/2014, 06:12
Pimager
 
Fecha de Ingreso: julio-2010
Mensajes: 298
Antigüedad: 13 años, 10 meses
Puntos: 8
Error en petición AJAX

Hola a todos, tengo un problema al intentar realizar una petición ajax en c#.
Estoy en la página "http://localhost/myPage.aspx" y mi código es el siguiente:
Javascript:
Código:
<script src="http://localhost/js/jquery-1.7.1.min.js"></script>
var params = '{cityID: 1}';
var utlToCall = 'http://localhost/myPage.aspx/GetCityInfo';
            $.ajax({
                url: utlToCall,
                data: params,
                dataType: 'json',
                type: 'POST',
                contentType: 'application/json',
                success: function (response) {
                    console.log(response);
                },
                error: function (data, status, jqXHR) {
                    console.log('ERROR data = ' + data);
                    console.log('ERROR status = ' + status);
                    console.log('ERROR jqXHR = ' + jqXHR);
                }
            });
Mi código C# en el servidor es:
Código:
using System.Web.Services;
public partial class myPage : BasePage
{
     protected void Page_Load(object sender, EventArgs e) {}
    [WebMethod]
    public static string GetCityInfo(string cityID)
    {
        return "Hello " + cityID + Environment.NewLine + "The Current Time is: "
        + DateTime.Now.ToString();
    }
}
Y cuando lo intento ejecutar me da error "NetworkError: 404 Not Found - http://localhost/myPageaspx/GetCityInfo"

Alguien sabe porqué sucede esto?
Alguna idea?

Muchas gracias