Colleagues Devs, I have an application in C # and ASP.NET with an Action that returns an array in JSON. When I return only one string I get handle with javascript now, when I return an array I do not know how to handle it in javascript.
Follow my Action:
public ActionResult ListaAcessoUsuario(int codEqpto, string login)
{
var acessoDao = new AcessoDAO();
var acessos = acessoDao.ListaAcessoUsuario(codEqpto, login);
return Json(acessos);
}
Follow my Html:
<table>
<thead>
<tr>
<th></th>
<th>Hora Inicio</th>
<th>Hora Fim</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dias Úteis</td>
<td id="HrIniU"></td>
<td id="HrFinU"></td>
</tr>
<tr>
<td>Sábados</td>
<td id="HrIniS"></td>
<td id="HrFinS"></td>
</tr>
<tr>
<td>Domingos</td>
<td id="HrIniD"></td>
<td id="HrFinD"></td>
</tr>
<tr>
<td>Feriados</td>
<td id="HrIniF"></td>
<td id="HrFinF"></td>
</tr>
</tbody>
<script type="text/javascript">
function atualizaCampos(Eqpto, usuario) {
var url = "@Url.Action("ListaAcessoUsuario", "Acesso")";
$.post(url, { codEqpto: Eqpto, login: usuario }, atualiza);
}
function atualiza(acessos) {
//aqui quero pegar o retorno da Action que é um array e exibir na tabela
}
</script>