Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (36 sloc) 1.28 KB
<title>Simple Node.js Example</title>
<script src=""></script>
<script src="./javascripts/jquery.tmpl.min.js"></script>
<script type="text/javascript">
$.ajax('', {
type: 'GET',
dataType: "JSON",
success: function(data) { $("#messageList").empty(); $("#messageTemplate").tmpl(data).appendTo("#messageList"); },
error : function() { alert("error"); }
<script id="messageTemplate" type="text/x-jquery-tmpl">
<div class="messageContainer">
<span class="messageMetadataLabel">To: </span><span>${recipient}</span> |
<span class="messageMetadataLabel">From: </span><span>${sender}</span> |
<span class="messageMetadataLabel">Sent at: </span><span>${senttimestamp}</span>
<div class="messageBody">${body}</div>
.body { font-family: Verdana; font-size: 1em; }
.messageContainer { background-color: #ccc; border: 4px solid lightblue; padding: 10px; margin: 10px; color: #333; }
.messageMetadataLabel { font-weight: bold; }
.messageBody { margin-top: 10px; }
<br />
<h1>Simple Node.js Message List Example:</h1>
<p id="messageList">
Something went wrong with that request. Please try again.