开发者

accessing the json return variable

I have an ajax call handled with jquery like this:

var GetAppointmentDate = "{'DateInput' : '02/02/2011'}";

$(function () {

    $("#mydiv").click(function () {

        $.ajax({
            type: "POST",
            url: "../Pages/Appointments.aspx/GetAppointements",
            data: GetAppointmentDate,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: successFn,
            error: errorFn
        });
    });
});

I've been debuggging the code behind to the point where I know the returned dat开发者_如何学运维a is what I want: the page method end with "return result;" and the variable result contains the json strong I need. Now how do I access the data returned in the front-end.

So far I have:

function successFn(){
    alert(msg.d);
};

Nothing's being outputted. What am I missing?


Change your success function to accept a parameter and then you can refer to the returned data. i.e:

function successFn(msg){
    alert(msg.d);
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜