I have this code that makes me a query an action of my controller, which returns a list in JSON
function CargPregRegist(valor) {
$.ajax({
type: 'POST',
url: '@Url.Action("CargPregTipo")',
data: "tipo=" + valor,
contentType: "application/x-www-form-urlencoded",
dataType: "json",
success: function (data) {
if (data) {
}
}
});
}
What I have thought to do is capture the result of data but with c # so I can make a query with razor, someone knows how I can read that data with c # ????? I'm working with asp.net mvc 5
part of what I have planned to do is this
@foreach (var m in t)
{
if (Model.Sto_TipoAlertas_Preguntas.lol(m.CodigoInterno1).TipoAlerta1 > 0)
{
<option value='@m.CodigoInterno1' selected>@m.DetallePregunta1</option>
}
else
{
<option value='@m.CodigoInterno1'>@m.DetallePregunta1</option>
}
}
What this part of the code has to do, select the ones that do comply with and show in a separate list now where is the 0 is what I'm going to replace by the way I get the result of ajax