相关疑难解决方法(0)

什么{"d":""}表示在asp.net webservice响应中

我创建了一个简单的C#asp.net Web服务函数,它返回一个字符串消息
,我使用jquery ajax从页面调用它.

C#:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld() {
    return DateTime.Now.ToString();
}
Run Code Online (Sandbox Code Playgroud)


JS:

    $(document).ready(function() {
    //alert("ready");
        $.ajax({
            type: "POST",
            contentType: "application/json; chatset=utf-8",
            url: "WebService2.asmx/HelloWorld",
            data: "{}",
            dataType: "json",
            success: function(msg) {
                //alert(msg); //doesnt works
                alert(msg.d);
            }
        });
    });
Run Code Online (Sandbox Code Playgroud)

我的问题是,为什么 alert(msg);犯规作品

.net asp.net web-services

7
推荐指数
2
解决办法
2780
查看次数

标签 统计

.net ×1

asp.net ×1

web-services ×1