Hi Experts!
I have created a webmethod:-
public class RailMapDoc : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
public void GetDocsCount(string locAddr)
{
using (Docs2GoEntities db = new Docs2GoEntities())
{
var docCount = db.LocDocMappings.Select(l => new { longitude = l.tblLocation.longitude, latitude = l.tblLocation.latitude, number_of_documents = db.LocDocMappings.Where(ld => ld.locationId == l.locationId && ld.V01_PR.V01_PG.PRONO == "ABKET").Count() }).Distinct();
HttpContext.Current.Response.Write(new JavaScriptSerializer().Serialize(docCount));
}
}
}
when I am executing this then it is giving link of service method i.e "GetDocsCount". using this link.
http://localhost:52517/RailMapDoc.asmx"
after invoking the method i am getting my json data.
how to consume this data using jquery, below is the code i am using to get the json data using jquery.
var GisMapWithTags = function () {
$.getJSON("RailMappDoc.asmx/GetDocsCount", function (json) {
jsonString = json;
}).done(function () {
ArcGisMap();
}).fail(function () {
alert("Error");
});
}
I am not able to get the data, where i am doing wrong please suggest me.
Thanks