【问题标题】:json to call a method [duplicate]json调用方法[重复]
【发布时间】:2014-02-13 13:25:08
【问题描述】:

我是新的 JSON。我编写了如下代码来调用 c# 中的方法。但它还没有全部调用该方法。请告诉我一个解决方案如何调用不带参数的 n 方法

$.ajax({
       type:"POST",
       url:"~/PageName.aspx/test",
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       success: function (msg) {
           alert("s");
       },error: function(msg){
           alert("error" + msg);
       }

       })

C#

public void test()
{

}

【问题讨论】:

    标签: c# json asp-classic asp.net-ajax


    【解决方案1】:

    如果方法在aspx页面后面,试试上面的方法。

    [WebMethod]
    public static string test()
       {
    
       }
    

    你也可以使用pagemethods

    【讨论】:

      【解决方案2】:

      【讨论】:

      • 我认为 Srujan0228 需要从 aspx 页面使用 webmethod。您发布的有关使用 WebRequest 使用服务的示例。
      猜你喜欢
      • 2016-03-31
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      • 2017-02-28
      • 2010-11-12
      • 2019-03-15
      • 2013-09-01
      • 1970-01-01
      相关资源
      最近更新 更多