xray1986
xray1986

Reputation: 1168

Ajax Call can't find webmethod

I have a dnn module and I am trying to make an ajax call in a page. My client code is:

$.ajax({
        type: "POST",
        url: "/DesktopModules/DMUI/Controls/Project/ProjectDrillingMapsView.ascx/GetMarkerList",
        dataType: "json"
    })
    .done(function (data) {
        var list = data;
        $.each(list, function (index, item) {
            alert(item);
     });
    })
    .fail(function (xhr, textstatus, errorthrown) {
     alert('Error:' + errorthrown + ', textstatus:' + textstatus);
    });

Server side I have this:

[WebMethod]
        public string GetMarkerList()
        {
            string output = null;
            List<Marker> markerList = new List<Marker>();
            //My main query where I get a list of Objects
            Expression<Func<DomainModel.Drilling, bool>> criteria = null;
            criteria = (d => d.ProjectId == this.SelectedProjectId && d.XCoordinate != 0 && d.YCoordinate != 0);
            _dpList = _drillingSrv.GetDrillingList(criteria, d => d.DrillingCode);

            foreach (DomainModel.Drilling dr in _dpList)
            {
                Marker marker = new Marker();
                marker.latitude = dr.GMapsLatitude.Value;
                marker.longitude = dr.GMapsLongitude.Value;
                marker.code = dr.DrillingCode;
                marker.depth = dr.Depth.Value;
                markerList.Add(marker);
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            output = jss.Serialize(markerList);
            return output;
        }

At first I was getting an Internal Server Error 500. Then I went into my web.config and did this: https://stackoverflow.com/a/2169847/1737287

Now I'm getting a Not Found Error 404. I'm curious as to what I might be doing wrong...

Upvotes: 1

Views: 596

Answers (1)

StartCoding
StartCoding

Reputation: 393

"The 404 or Not Found error message is a HTTP standard response code indicating that the client was able to communicate with a given server, but the server could not find what was requested."

Provide full URL in ajax call.

Upvotes: 1

Related Questions