1
我想從API獲取數據後呈現文件。如何從jQuery渲染ejs?
代碼
$(document).ready(function() {
$(document).delegate("#editUser", "click", function() {
var userId = $(this).data('id');
$.post("/userProfile",{"userId":userId},function(data, status){
console.log(data); //gets data here
//how to render ejs file here with the above data?
});
});
EJS文件:(sample.ejs)
<% include header.html %>
<strong>Sample ejs</strong>
<ul>
<li><%= data.name %> says: <%= data.message %></li>
</ul>
<% include footer.html %>
我怎樣才能解決這個問題?