JSON and Prototype

Posted on 2011-02-14
Last Modified: 2013-09-30
please help me use prototype to populate the 'title' div with the data inside this JSON.
    "blogPosts" : [
"postTitle" : "My Blog post title",
            "content" : "my main content",
            "image" : "th-4.jpg",

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

Question by:ram0nm
LVL 40

Expert Comment

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

check this also

Author Comment

ID: 34890379
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

LVL 40

Expert Comment

ID: 34890394
try it

document.getElementById("title").innerHTML = eval(JSON).blogPosts.postTitle;
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

LVL 40

Expert Comment

ID: 34890408
LVL 82

Accepted Solution

leakim971 earned 500 total points
ID: 34903847
The path to get the title is :
or :

To set the innerHTML you should use update :

Open in new window

Test page :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src=""></script>
<script language="javascript">
	var myJson = {"blogPosts":[{"postTitle":"My Blog post title","content":"my main content","image":"th-4.jpg"}]};
	Event.observe(window, 'load', function() {
<div id="title"></div>

Open in new window

LVL 58

Expert Comment

ID: 39495092
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
LVL 82

Expert Comment

ID: 39495093
My last comment fully answered the question :
- use prototype instead jQuey
- show the path to the data
- working example provided

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question