Robson, você também pode utilizar uma template engine para montar o seu HTML, abaixo segue um exemplo com Handlebars
vou utilizar o seguinte JSON no exemplo:
var model = {
Data: new Date(),
Pessoas: [
{"firstName":"Meire","lastName":"Melo","jobTitle":"Direct Marketing Agent","title":"Product Branding Analyst"},
{"firstName":"Júlio César","lastName":"Reis","jobTitle":"Dynamic Web Designer","title":"Global Usability Designer"},
{"firstName":"Esther","lastName":"Silva","jobTitle":"Customer Marketing Technician","title":"International Metrics Director"},
{"firstName":"Kléber","lastName":"Moreira","jobTitle":"Global Paradigm Engineer","title":"Investor Metrics Planner"},
{"firstName":"Gúbio","lastName":"Macedo","jobTitle":"Dynamic Configuration Assistant","title":"Human Response Orchestrator"},
{"firstName":"Norberto","lastName":"Albuquerque","jobTitle":"Central Optimization Planner","title":"Customer Optimization Manager"},
{"firstName":"Dalila","lastName":"Oliveira","jobTitle":"Dynamic Data Producer","title":"Product Accountability Manager"},
{"firstName":"Yuri","lastName":"Reis","jobTitle":"Dynamic Functionality Specialist","title":"Dynamic Usability Technician"},
{"firstName":"Vicente","lastName":"Pereira","jobTitle":"Senior Optimization Strategist","title":"Central Accountability Producer"},
{"firstName":"Elísio","lastName":"Saraiva","jobTitle":"Internal Division Producer","title":"Dynamic Interactions Engineer"},
{"firstName":"Lorraine","lastName":"Braga","jobTitle":"Corporate Security Strategist","title":"Corporate Creative Coordinator"},
{"firstName":"Guilherme","lastName":"Albuquerque","jobTitle":"Internal Accountability Agent","title":"Senior Research Developer"},
{"firstName":"Rafaela","lastName":"Melo","jobTitle":"Corporate Paradigm Orchestrator","title":"National Division Manager"},
{"firstName":"Heitor","lastName":"Reis","jobTitle":"Dynamic Integration Assistant","title":"Chief Brand Engineer"},
{"firstName":"Sílvia","lastName":"Martins","jobTitle":"Principal Division Engineer","title":"Global Configuration Analyst"},
{"firstName":"Alessandro","lastName":"Carvalho","jobTitle":"Direct Security Planner","title":"Direct Tactics Architect"},
{"firstName":"Roberta","lastName":"Macedo","jobTitle":"Lead Metrics Orchestrator","title":"Dynamic Mobility Analyst"},
{"firstName":"Silas","lastName":"Moreira","jobTitle":"Direct Communications Manager","title":"Regional Functionality Planner"},
{"firstName":"Marli","lastName":"Moraes","jobTitle":"Lead Accounts Technician","title":"Senior Assurance Consultant"},
{"firstName":"Meire","lastName":"Braga","jobTitle":"District Interactions Manager","title":"Forward Web Officer"}
]
};
o template será o seguinte:
<div>
<label>
Data:
<input type="text" value="{{formatDate Data}}" />
</label>
</div>
<div>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Sobrenome</th>
<th>Profissão</th>
<th>Titulo</th>
</tr>
</thead>
<tbody>
{{#each Pessoas}}
<tr>
<td>{{firstName}}</td>
<td>{{lastName}}</td>
<td>{{jobTitle}}</td>
<td>{{title}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
o markup
acima você pode colocar dentro e uma tag <script type="text/x-handlebars-template"></script>
ou de uma <template></template>
para montar o template e o html final, você pode fazer assim:
var source = document.getElementById("id do templete").innerHTML;
var template = Handlebars.compile(source);
var html = template(model);
Agora o exemplo completo:
Handlebars.registerHelper('formatDate', function(data, options) {
return data.toISOString().substring(0, 10);
});
function createElement (html) {
var template = document.createElement("template");
template.innerHTML = html;
return document.importNode(template.content, true);
}
var model = {
Data: new Date(),
Pessoas: [
{"firstName":"Meire","lastName":"Melo","jobTitle":"Direct Marketing Agent","title":"Product Branding Analyst"},
{"firstName":"Júlio César","lastName":"Reis","jobTitle":"Dynamic Web Designer","title":"Global Usability Designer"},
{"firstName":"Esther","lastName":"Silva","jobTitle":"Customer Marketing Technician","title":"International Metrics Director"},
{"firstName":"Kléber","lastName":"Moreira","jobTitle":"Global Paradigm Engineer","title":"Investor Metrics Planner"},
{"firstName":"Gúbio","lastName":"Macedo","jobTitle":"Dynamic Configuration Assistant","title":"Human Response Orchestrator"},
{"firstName":"Norberto","lastName":"Albuquerque","jobTitle":"Central Optimization Planner","title":"Customer Optimization Manager"},
{"firstName":"Dalila","lastName":"Oliveira","jobTitle":"Dynamic Data Producer","title":"Product Accountability Manager"},
{"firstName":"Yuri","lastName":"Reis","jobTitle":"Dynamic Functionality Specialist","title":"Dynamic Usability Technician"},
{"firstName":"Vicente","lastName":"Pereira","jobTitle":"Senior Optimization Strategist","title":"Central Accountability Producer"},
{"firstName":"Elísio","lastName":"Saraiva","jobTitle":"Internal Division Producer","title":"Dynamic Interactions Engineer"},
{"firstName":"Lorraine","lastName":"Braga","jobTitle":"Corporate Security Strategist","title":"Corporate Creative Coordinator"},
{"firstName":"Guilherme","lastName":"Albuquerque","jobTitle":"Internal Accountability Agent","title":"Senior Research Developer"},
{"firstName":"Rafaela","lastName":"Melo","jobTitle":"Corporate Paradigm Orchestrator","title":"National Division Manager"},
{"firstName":"Heitor","lastName":"Reis","jobTitle":"Dynamic Integration Assistant","title":"Chief Brand Engineer"},
{"firstName":"Sílvia","lastName":"Martins","jobTitle":"Principal Division Engineer","title":"Global Configuration Analyst"},
{"firstName":"Alessandro","lastName":"Carvalho","jobTitle":"Direct Security Planner","title":"Direct Tactics Architect"},
{"firstName":"Roberta","lastName":"Macedo","jobTitle":"Lead Metrics Orchestrator","title":"Dynamic Mobility Analyst"},
{"firstName":"Silas","lastName":"Moreira","jobTitle":"Direct Communications Manager","title":"Regional Functionality Planner"},
{"firstName":"Marli","lastName":"Moraes","jobTitle":"Lead Accounts Technician","title":"Senior Assurance Consultant"},
{"firstName":"Meire","lastName":"Braga","jobTitle":"District Interactions Manager","title":"Forward Web Officer"}
]
};
var source = document.getElementById("tmpl").innerHTML;
var template = Handlebars.compile(source);
var html = template(model);
var elem = createElement(html);
document.body.appendChild(elem);
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.js"></script>
<script id="tmpl" type="text/x-handlebars-template">
<div>
<label>
Data:
<input type="date" value="{{formatDate Data}}" />
</label>
</div>
<div>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Sobrenome</th>
<th>Profissão</th>
<th>Titulo</th>
</tr>
</thead>
<tbody>
{{#each Pessoas}}
<tr>
<td>{{firstName}}</td>
<td>{{lastName}}</td>
<td>{{jobTitle}}</td>
<td>{{title}}</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</script>
minhaCallBack
ou em código chamado a partir dela.