Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 找不到对HelloWorld的Asp.net jquery页方法调用_C#_Jquery_Asp.net_Web Services_Pagemethods - Fatal编程技术网

C# 找不到对HelloWorld的Asp.net jquery页方法调用

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"

我正在尝试运行一个基本测试,以便从WebService.asmx页面运行helloworld,但通过调试发现,它甚至没有到达WebService.asmx页面中的page方法。我已经为此工作了一整天,非常感谢您的帮助。这是我的密码

[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()]