Jquery &引用;“未定义”;从asp.net中的web服务获取数据后的结果

Jquery &引用;“未定义”;从asp.net中的web服务获取数据后的结果,jquery,asp.net,web-services,Jquery,Asp.net,Web Services,很抱歉打扰你,但我需要帮助。 我想从asp.net中的Web服务获取数据。我已从下一个JQuery调用该服务: $(document).ready(function () { $("#btn").click(function () { var name = ""; $.ajax({ type: "POST", contenttype: "ap

很抱歉打扰你,但我需要帮助。 我想从asp.net中的Web服务获取数据。我已从下一个JQuery调用该服务:

        $(document).ready(function () {
             $("#btn").click(function () {

            var name = "";
            $.ajax({
                type: "POST",
                contenttype: "application/json; charset=utf-8",
                data: "{null}",
                url: "EmployeeInfo.asmx/GetEmployeeInfo",
                dataTyp: "json",
                success: function (res) {
                    name = res.d;
                    alert(name);

                },
                error: function (err) {
                    alert(err);
                }
            });


        }); 
    });          
我将从DB获取员工姓名,但下一个代码仅用于测试:

[WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public string GetEmployeeInfo()
    { 
        return "John";
    }
问题是,由于检索到的值,我得到了“未定义”的结果。我错过什么了吗

谢谢大家的努力和帮助

$(document).ready(function () {
    $("#btn").click(function () {
        var name = "";
        $.ajax({
            type: "POST",
            url: "*youepage.aspx*/GetEmployeeInfo",
            data: "",
            contentType: "application/json",
            dataType: "json",
            success: function (response) {
                name = response.d;
                alert(name);
            },
            error: function (response) {
                alert(response);
            }
        });
    }); 
});    
对于测试: 在同一页(您的.aspx)中,转到代码隐藏并编写:

[WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static string GetEmployeeInfo()
    {
        return "jack";
    }

感谢您的帮助,但不幸的是,相同的结果(未定义):(更新答案以完善工作示例,将url更改为您的.aspx页面名称并添加代码behindI不希望它访问同一页面,我希望它调用.asmx文件中的方法。