After making an ajax call, I received the following output:
"total":"3",
"data":[{ "id":"4242",
"title":"Yeah Lets Go!",
"created":"1274700584",
"created_formated":"2010-07-24 13:19:24",
"path":"http:\/\/domain.com\/yeah"
}]
The output contains three items in an array. I need to iterate through them and generate HTML output on the page like this:
Yeah Lets Go! (which is a link to http:www.domain.com/yeah)
Created: 2010-07-24 13:19:24
I'm having trouble figuring this out.
Edit 1:
Currently, I only get the raw output after clicking the link. How can I make it show on page load instead of making an ajax call when clicking the link?
Edit 2:
I managed to output everything at once. But I'm still struggling with converting it into actual HTML. The current output is:
"total":"3",
"data":[{
"id":"4242",
"title":"Yeah Lets Go!",
"created":"1274700584",
"created_formated":"2010-07-24 13:19:24",
"path":"http:\/\/domain.com\/yeah"
}
{
"id":"4242",
"title":"Yeah Lets Go!222",
"created":"1274700584",
"created_formated":"2010-07-24 13:19:24",
"path":"http:\/\/domain.com\/yeah222"
}
{
"id":"4242",
"title":"Yeah Lets Go!333",
"created":"1274700584",
"created_formated":"2010-07-24 13:19:24",
"path":"http:\/\/domain.com\/yeah333"
}
]}
I want to display this in a list format with the title, link, and creation date.
Edit 3 after answer from Luca Matteis:
I'm even more confused now.
The JSON string is a result of the following code:
$('a.link').click(function() {
var item_id = $(this).attr("href").split('#')[1];
$.get(base_url+'/ajax/get_itema/'+item_id+'/0/3/true',
null,
function(data, status, xhr) {
$('#contentCell').html(data);
}
);
To proceed, should I use something like:
var html = eval(data);
and then follow Luca Matteis suggestion?