Reputation: 171
I have some files up on Parse.com and want to pull them down using JSON. After I pull down the json data I wish to display this on a HTML page. One of the elements I am pulling down is nested and contains the objectID of a element I wish to make a further call to.
Here is the line I am stuck with:
document.getElementById("subjectName").innerHTML=subject.exam.objectId;
This is setting a HTML tag to undefined. If I have a similar structure such as:
document.getElementById("subjectName").innerHTML=subject.exam.className;
it will set the element as expected. The JSON data I am pulling down is as follows
{
"exam": {
"__type": "Pointer",
"className": "exam",
"objectId": "UP7CeBZNz8"
},
"name": "Computer Architecture",
"objectId": "Pf1tKLYzjz",
"createdAt": "2014-04-24T09:22:22.732Z",
"updatedAt": "2014-04-29T16:21:40.855Z"
}
If anyone can help with this it would be much appreciated!
Upvotes: 0
Views: 61
Reputation: 5855
The problem might be because you're setting it to the same element.
if you have used
document.getElementById("subjectName").innerHTML
in both the assignments, it will not work. this works:
document.getElementById("objectId").innerHTML=subject.exam.objectId;
document.getElementById("subjectName").innerHTML=subject.exam.className;
Fiddle here
Upvotes: 1