0
I need to receive a Json with the selection of activities and generate the HTML according to this data.
I believe that it should be more or less like this, someone can give me some hint to improve?
<script>
$(document).ready(function () {
var CodigoMilestone = $("#CodigoMilestone");
$.ajax({
type: "GET",
url: "/Dashboard/GetAtividades",
sucess: function (atividades) {
if (atividades != null) {
$(atividades).each(function (i) {
var div = "<div> <table>";
var tr = "<tr>";
div +=
tr += "<td>" + atividades[i].InicioCedo;
tr += "<td>" + atividades[i].TempoRevisado;
tr += "<td>" + atividades[i].TerminoCedo;
div.append(tr);
tr += "<td>";
tr += "<td>" + atividades.Descricao;
tr += "<td>";
div.append(tr);
tr += "<td>" + atividades[i].InicioTarde;
tr += "<td>" + atividades[i].Folga;
tr += "<td>" + atividades[i].TerminoTarde;
div.append(tr);
})
}
}
})
});
Below a Json object:
[{"Codigo":7,"Descricao":"Atividade 1","CodigoMilestone":6,"TempoRevisado":2,"Inicio":"\/Date(1445738400000)\/","InicioCedo":"\/Date(1445738400000)\/","InicioTarde":"\/Date(-62135589600000)\/","TerminoCedo":"\/Date(1445911200000)\/","TerminoTarde":"\/Date(-62135589600000)\/","Ativo":true,"Milestone":null,"Dependencia":[],"Dependencia1":[]},{"Codigo":8,"Descricao":"Ativade 2","CodigoMilestone":6,"TempoRevisado":2,"Inicio":"\/Date(1445997600000)\/","InicioCedo":"\/Date(1445997600000)\/","InicioTarde":"\/Date(1445911200000)\/","TerminoCedo":"\/Date(1446084000000)\/","TerminoTarde":"\/Date(1446084000000)\/","Ativo":true,"Milestone":null,"Dependencia":[],"Dependencia1":[]}]
Put the Object of activities to see how it looks, this having some problem or and only matter of code optimization/ produce a more elegant code ?
– Gabriel Rodrigues
I edited my question. It’s not working yet.
– user31040
if you make a
console.log(atividades);
you get some feedback from php ?– Gabriel Rodrigues
My project is in ASP.net MVC
– user31040
I understood, the mistake is in your div, I will make an example
– Gabriel Rodrigues