Question

I'm trying to call a ASP.NET WebMethod from a javascript function but every time I try it returns me the error 500

Javascript:

function enviarParaASP() {
        jQuery.ajax({
            url: 'GoogleMapsGeolocation.aspx/SalvaCoordenadas',
            type: "POST",
            data: "{'coord' : " + coordenadaASalvar + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "script",
            //beforeSend: function () {
            //    alert("Start!!! ");
            //},
            success: function (msg) {
                alert("OK ");
            },
            failure: function (msg) { alert("Sorry!!! "); }
        });
    }

ASP.NET:

[WebMethod]
        public void SalvaCoordenadas(object coord)
        {
            //do something
        }

UPDATING...

I found the solution, was just to add "STATIC" to the webmethod like this:

[WebMethod]
        public static void SalvaCoordenadas(object coord)
        {
            //do something
        }

thanks for the help, now I want to know how to debugg the server :P

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top