无法获取Jquery.Ajax()成功时的数据/响应

时间:2014-03-28 07:50:00

标签: javascript jquery ajax json webmethod

嗨,大家好,我过去3天都渴望自己,而且我无法找到在浏览器上看到json响应的方法

Json response seen on firebug

这是我的Ajax代码:

$("[id*=btnModalPopup]").live("click", function () {

    $("#tblCustomers tbody tr").remove();

    $.ajax({
        type: "POST",
        url: "CallDataThroughJquery.aspx/GetLeadDetails",
        data: '{}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
        alert("Hi Json");
        alert(data.Leadno);  // **Says data.leadno is undefined**

        response($.map(data.d, function (item) {  // **here I am going some where wrong**
         //**cannot catch response. Help!**

        }))

        },
        failure: function (response) {
            alert(response.d);
        }
    });
});

请帮助我...提前致谢!

2 个答案:

答案 0 :(得分:1)

我看到你的JSON是一个带有对象的数组。尝试数据[0] .Leadno

答案 1 :(得分:0)

$.ajax({
    type: "POST",
    url: "CallDataThroughJquery.aspx/GetLeadDetails",
    data: '{}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
    alert("Hi Json");
    alert(data.d[0]['Leadno']);  // **Says data.leadno is undefined**

    response($.map(data.d, function (item) {  // **here I am going some where wrong**
     //**cannot catch response. Help!**

    }))

    },
    failure: function (response) {
        alert(response.d);
    }
});

使用' data.d [0] [' Leadno']'来尝试提醒。