I have this view that populates an unordered list from values in a JSON file, which I am doing in Node.
Is there a better way to do this, or a more 'node-like' way? Can I load the JSON file without an Ajax call?
<!DOCTYPE html>
<html>
<head>
<title>4·pli -- news</title>
<link rel='stylesheet' href='/stylesheets/style.css'/>
<script src="/javascripts/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/javascripts/date.format.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=Didact+Gothic' rel='stylesheet' type='text/css'>
</head>
<body>
<% include shared/nav.ejs %>
<div class="wrapper">
<ul class='news'>
<script type="text/javascript">
$.ajax({
url: 'data/news.json',
async: false,
dataType: 'json',
success: function (response) {
var items = [];
$.each(response.news,function(i,item){
items.push('<li><ul><li class="title">'+ item.title +'</li><li>' + dateFormat(item.created_at,"fullDate") + '</li><li><p>'+ item.content +'</p></li></ul></li>');
});
$('.news').append(items.join(''));
}
});
</script>
</ul>
</div>
<% include /shared/footer.ejs %>
</body>
</html>
async: false
--- baaaad – Jan Dvorak May 16 '13 at 20:37