javascript - asp.net c# 4.5 Call To WebMethod Does Not Return Anything -
i have simple webmethod call not return anything. receive no errors.
the code simple. wonder if there setting (iis, webconfig, etc.) not correct. have vs pro 2013, framework = 4.5 , iis 10.0 express.
any thoughts on why "hello world!" program not work?
javascript.aspx.cs
using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.web.services; namespace webapplication1 { public partial class javascript : system.web.ui.page { protected void page_load(object sender, eventargs e) { } [webmethod] public static string getdata() { return "hello world!"; } } }
javascript.aspx.cs
<%@ page language="c#" autoeventwireup="true" codebehind="javascript.aspx.cs" inherits="webapplication1.javascript" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function () { $.ajax({ type: "post", url: "javascript.aspx/getdata", contenttype: "application/json; charset=utf-8", datatype: "json", success: function (response) { $("#content").text(response.d); }, failure: function (response) { alert(response.d); } }); }); </script> </head> <body> <form id="frm" method="post"> <div id="content"> </div> </form> </body> </html>
since cannot post images (not enough reputation points), please click link see network tab: here network tab
Comments
Post a Comment