0

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 data 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?

1 Answer 1

2

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);
};
Sign up to request clarification or add additional context in comments.

4 Comments

ok, this worked. Now the problem is that in the return string I have some dates that are formatted like this: "AppointmentTime":"\/Date(1296625740000)\/" Do I need to do some sort of processing to convert the date, or even the whole returned variable, into json that's properly formatted?
Can you get the JSon without wrapping the numeric value in Date()? And is the numeric value Milliseconds?
I don't understand? The native type of the property is a date; what do you recommend I do?
In the sample JSON you have posted, can you get the value of AppointmentTime as "AppointmentTime":"1296625740000"?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.