$('document').ready(function() 
    { 
        $.getJSON('news.php', parseInfo);
});

function parseInfo(data)
{
    alert(data.news);//undefined
    $('#info').html(data.news);
}

My PHP output(news.php) is [{"id":"20110428","news":"april 28 2011"}]

Comments

Always give upvote to the genuine answer that really helps you, and finally select the best suited answer as correct one... :-)

Written by Nirmal

Accepted Answer

Your object is wrapped inside an array.

You need data[0].news

Alternatively remove the outer square brackets from your JSON output.

Written by Alnitak
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki