[webmethod] [ScriptMethod(ResponseFormat=ResponseFormat.Json)] public static List<Problem> GetProblems() { List<Problem> allproblems = new List<Problem>(); using (TMEntities tm = new TMEntities()) { allproblems = tm.Problems.ToList(); } return allproblems; }
<script type="text/javascript"> $(document).ready(function () { $.ajax({ type:"POST", url: "WebForm1.aspx/GetProblems", data: "{}", datatype: "json", contentType: "application/json; charset=utf-8", success: function (data) { alert('success'); }, failure: function (response) { alert("fail"); } }); }); </script>
url: "WebForm1.aspx/GetProblems",
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)