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);
- };
- HttpContext.Current.Session["ID"] = id;
- result = DataSetToJSON(dt);
- return result;
- }
- catch (Exception ex) {
- throw new Exception();
- }
- }
jquery
- <script type="text/javascript">
- $(function () {
-
- var RegNo = '';
- var Status = '';
- var latit = '';
- var longi = '';
- var ID = '<%=Session["ID"]%>'.val();
- var obj = {};
- obj.ID=ID;
- getdata(obj);
- return false;
-
- });
-
- function getdata(obj) {
-
- $.ajax({
- type: "POST",
- url: "home.aspx/info",
- contentType: "application/json;charset=utf-8",
-
- data: { ID: obj.ID }
- datatype: "json",
- async: true,
- cache: false,
- success: function (result) {
-
-
-
- },
- error: function (error) {
- alert(error);
- alert("error");
- }
- });
- }
-
-
- </script>
try to pass id through web method in this line data:JSON.stringify(obj.ID),
when i do this there is error on console
Uncaught TypeError: "442".val is not a function
when i remove .val() then this show error
Failed to load resource: the server responded with a status of 500 (Internal Server Error)