I try this method to get data and also i have try jquery . In jquery i call info method
[WebMethod] public static string info(string id) { try { string result = ""; Entities er = new Entities(); List < sp_web_Result > sv = er.sp_web(id).ToList(); DataTable dt = new DataTable(); dt.Columns.Add("No", typeof(string)); dt.Columns.Add("Latitude", typeof(float)); dt.Columns.Add("Longitude", typeof(float)); foreach(var c in sv) { dt.Rows.Add(c.No, c.Longitude, c.Latitude); }; result = DataSetToJSON(dt); return result; } catch (Exception ex) { throw new Exception(); } }
jquery
<script type="text/javascript"> $(function () { var obj = {}; getdata(obj); return false; }); function getdata(obj) { var RegNo = ''; var Status = ''; var latit = ''; var longi = ''; $.ajax({ type: "POST", url: "home.aspx/info", contentType: "application/json;charset=utf-8", data: "{'id':'442'}", datatype: "json", async: true, cache: false, success: function (result) { //map code }, error: function (error) { alert(error); alert("error"); } }); } </script>
in jquery there is line data: "{'id':'442'}",
now i want to pass id through web method in this line i hard code id but i want id through web method how to save id and call id in this line