Hi,

I'm trying JSON for the first time and I have a php file that returns this:

[{"userID":"39160902151","content":"I really can't wait to get this thing done :-)","published":"2011-06-07 10:33:35"}]

.

What do I do if I want to display only the userID from this data using javascript. I load this into javascript like this:

var displayfeeds = new ajaxObject('ajax/users/display.feeds.php');
    displayfeeds.callback = function (responseText,status) {
	var feed = JSON.parse(JSON.stringify(responseText));
	$("#feeds-feedback").html(feed);//I need the userID from feed
}
    displayfeeds.update();

Thank you in anticipation :-)

I suspect that (if this works) you need feed[0].userID . If that doesn't work, try to log feed ( console.log(feed); ), look at your browser's log, and figure out what feed is.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.