2

I have jquery ajax call , and this is the code for successful response

success: function (msg) {
                    console.log(msg.d);
                    var Ticket = msg.d;
                    console.log(Ticket);
                }

The first console.log returns an object of exactly what I want, here is a part of what it looks like in console.

[
Object
CouponCode: null
DateCreated: "10/31/2012 12:00:00 AM"
EndDate: "11/23/2012"
EventID: "47c30437-fb5a-461f-9990-a95cc23f1d55"

The actual ajax response from webmethod.

{"d":[{"__type":"Ticket","rsID":"240bac97-b97b-4d89-ac48-cd692c66a7ad","EventID":"47c30437-fb5a-461f-9990-a95cc23f1d55","Title":  ....

How can I access this object?? you see from the console response , now I want the EventID

and

var Ticket = msg.d;  //this is what I showed from console
var Ticket = $.parseJSON(msg.d);  //returns null
console.log(Ticket.EventID);  //returns null
console.log(Ticket);  // returns null

How can I access this msg.d ???>

1 Answer 1

3

It looks to me like you have an array of objects, and Ticket is a reference to that array. Even if there is only one object in it, you will need to reference that in the array. Try this:

console.log(Ticket[0].EventID);
Sign up to request clarification or add additional context in comments.

2 Comments

Damn... I just got done telling someone about how smart I was too :( , well 25 easy points for you
@ScottSelby - Well you setup the service and managed to return serialized json. Looks good to me, just got caught up on something simple. Happens to everyone :)

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.