C# 找不到对HelloWorld的Asp.net jquery页方法调用
我正在尝试运行一个基本测试,以便从WebService.asmx页面运行helloworld,但通过调试发现,它甚至没有到达WebService.asmx页面中的page方法。我已经为此工作了一整天,非常感谢您的帮助。这是我的密码C# 找不到对HelloWorld的Asp.net jquery页方法调用,c#,jquery,asp.net,web-services,pagemethods,C#,Jquery,Asp.net,Web Services,Pagemethods,我正在尝试运行一个基本测试,以便从WebService.asmx页面运行helloworld,但通过调试发现,它甚至没有到达WebService.asmx页面中的page方法。我已经为此工作了一整天,非常感谢您的帮助。这是我的密码 [WebMethod] public static string HelloWorld() { return "Hello World"; } function test() { $.ajax({ type: "POST"
[WebMethod]
public static string HelloWorld()
{
return "Hello World";
}
function test() {
$.ajax({
type: "POST",
url: "EmployeesWebService.asmx/HelloWorld",
data: "{}",
success: OnSuccess,
failure: OnFailure,
error: OnError
});
}
我已经尝试了很多不同的方法,但我总是会出错。我还未注释[System.Web.Script.Services.ScriptService]
这里还有我的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>
您需要放上括号,还应该放上结果格式。将方法属性更改为此
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod()]