1
Devs, I have a C# and ASP.NET application with an Action that returns a JSON array. When I return only a string I can deal with javascript now, when I return an array I don’t know how to handle 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);
}
Follows 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>
That’s right Lucas. Thank you very much!
– Diego Grossi