You need to put the parentheses, and you should put a result format as well. Change the method attributes to this...
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod()]
문제
I'm trying to run a basic test to get Hello World running from the WebService.asmx page but I found out through debugging that its not even reaching the page method in the WebService.asmx page. I been working for about an entire day on this and I would greatly appreciate your help. Here's my code.
[WebMethod]
public static string HelloWorld()
{
return "Hello World";
}
function test() {
$.ajax({
type: "POST",
url: "EmployeesWebService.asmx/HelloWorld",
data: "{}",
success: OnSuccess,
failure: OnFailure,
error: OnError
});
}
I've tried many variations of this and I keep getting an error. I also have [System.Web.Script.Services.ScriptService] uncommented.
Also heres my web.config
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Scheduling.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
</configuration>
해결책
You need to put the parentheses, and you should put a result format as well. Change the method attributes to this...
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod()]