1

我有这个简单的网络服务

<WebMethod()> _
 Public Function HelloWorld() As String
    Return "[1255545454545,4]"
 End Function

这将在客户端 >

      $.ajax({
          type: "POST",
          url: "WebService1.asmx/HelloWorld",
          data: "{}",
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function(response) {
              alert(response);
          },
          failure: function(msg) {
              alert(msg);
          }
      });
  });

我怎样才能拥有真正的价值而不是我得到的 [object object]

4

1 回答 1

4

尝试访问 response.d。这是一个 Asp.Net 功能。

$.ajax({
      type: "POST",
      url: "WebService1.asmx/HelloWorld",
      data: "{}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(response) {
          alert(response.d);
          alert(response.d[0]);
          alert(JSON.stringify(response));
      },
      failure: function(msg) {
          alert(msg);      
      }
  });

http://encosia.com/never-worry-about-asp-net-ajaxs-d-again/

于 2012-04-23T20:37:51.917 回答