c# - Ajax call returning 500 error in Asp.Net Web application -
i have trying sending ajax
request server in web application, return me 500
internal server error
following code
test.aspx
<script src="assets/plugins/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript"> var postdata = json.stringify( { "name": "rakeev", "age": "28" });; function testjson() { $.ajax({ type: "post", contenttype: "application/json; charset=utf-8", url: "test.aspx/getid", data: "{json: '" + postdata + "'}", datatype: "json", success: function (result) { alert("c"); }, error: function (xhr, ajaxoptions, thrownerror) { alert(xhr.status); alert(thrownerror); } }); } </script> </head> <body> <form id="form1" runat="server"> <input type="button" value="text" onclick="testjson()" / > </form> </body>
test.aspx.cs
namespace testapp { public partial class test : system.web.ui.page { [system.web.services.webmethod] public static int64 getid(string data) { using (joyrydeanalysis.data.joyryde_analyzerentities context = new joyrydeanalysis.data.joyryde_analyzerentities()) { var id = context.tbl_item_list.where(x => x.txt_item_name == data).select(x => x.lng_item_id).firstordefault(); return id; } } protected void page_load(object sender, eventargs e) { } } }
is there other method used send ajax call in asp.net webapplication ?
Comments
Post a Comment