Link to home
Start Free TrialLog in
Avatar of ram0nm
ram0nmFlag for United States of America

asked on

JSON and Prototype

please help me use prototype to populate the 'title' div with the data inside this JSON.
      
JSON:
{
    "blogPosts" : [
        {
"postTitle" : "My Blog post title",
            "content" : "my main content",
            "image" : "th-4.jpg",
            }
    ]
}

html: <div id="title"></div>

Thanks!
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

document.getElementById("title").innerHTML = JSON.blogPosts.postTitle;

check this also
http://api.jquery.com/jQuery.getJSON/
Avatar of ram0nm

ASKER

That didn't work. btw I needed this to be done using prototype not jQuery.

I think in prototype it should look like this, but it's still not working, not sure what I'm doing wrong:
$('title').innerHTML = JSON.blogPosts.postTitle; 

Open in new window

try it

document.getElementById("title").innerHTML = eval(JSON).blogPosts.postTitle;
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
My last comment fully answered the question :
- use prototype instead jQuey
- show the path to the data
- working example provided