JQuery - selecione objeto JSON aleatório
Eu tenho esse código jquery para gerar as entradas em um arquivo JSON no carregamento da página ...
$.getJSON('b.json', function(data) {
$('#dictionary').empty().hide();
$.each(data, function(entryIndex, entry) {
var html = '<div class="entry">';
html += '<h3 class="title">' + entry['title'] + '</h3>';
html += '<div class="link_url">' + entry['link_url'] + '</div>';
html += '<div class="image_src">';
html += entry['image_src'];
if (entry['quote']) {
html += '<div class="quote">';
$.each(entry['quote'], function(lineIndex, line) {
html += '<div class="quote-line">' + line + '</div>';
});
if (entry['author']) {
html += '<div class="quote-author">' + entry['author'] + '</div>';
}
html += '</div>';
}
html += '</div>';
html += '</div>';
$('#dictionary').append(html).fadeIn();
});
});
O que eu preciso fazer é carregar uma dessas entradas, aleatoriamente.
Qualquer conselho apreciado.
Muito obrigado, C
O arquivo JSON é ...
[
{
"title": "WESITE NAME",
"link_url": "http://www.website.com",
"image_src": "http://www.website.com/images/recent.jpg",
},
{
"title": "WESITE NAME",
"link_url": "http://www.website.com",
"image_src": "http://www.website.com/images/recent.jpg",
},
{
"title": "WESITE NAME",
"link_url": "http://www.website.com",
"image_src": "http://www.website.com/images/recent.jpg",
}
]