3

I am trying to get data from an object. I have tried to get the data as a.doc._id as given below.

function ab(data){alert("content is "+data.doc.id);}

enter image description here

Shoaib Chikate
  • 8,665
  • 12
  • 47
  • 70
ess
  • 663
  • 3
  • 9
  • 17
  • Can you put the object structure in you question description? – Rutwick Gangurde Feb 07 '14 at 06:05
  • possible duplicate of [How to access object properties containing special characters?](http://stackoverflow.com/questions/12953704/how-to-access-object-properties-containing-special-characters) – Felix Kling Feb 07 '14 at 06:22

2 Answers2

4

You probably need to access the property using the square bracket notation. Try -

alert("sdf" + data["doc._id"]);
MD Sayem Ahmed
  • 28,628
  • 27
  • 111
  • 178
0

"doc" is not an object, as shown in the inspector, you should rename the property name to something like doc-title instead.

Otherwise, you should create the object something like this

var data = {
             "act" : "",
             "doc": {
                 "_id" : "9",
                 "title": "fghfgh"
             }
           };
Lee Gary
  • 2,357
  • 2
  • 22
  • 38