javascript function receives values but fields are not receiving values.
Controller function
public JsonResult GetSequencia(DateTime dataAbate)
{
db.Configuration.ProxyCreationEnabled = false;
var lote = db.Lotes.Where(p => p.DataAbate == dataAbate).ToList();
if (lote.Count <= 0)
{
var loteNull = db.Lotes.ToList();
loteNull.Add(new Lote
{
SequenciaInicial = 123,
SequenciaFinal = 456
});
return Json(loteNull);
}
return Json(lote);
}
Javascript function within SECTION SCRIPTS
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
$(document).ready(function () {
$("#DataAbate").change(function () {
$("#SequenciaInicial").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("GetSequencia")',
dataType: 'json',
data: { dataAbate: $("#DataAbate").val() },
success: function (data) {
$.each(data, function (i, data) {
$("#SequenciaInicial").append(data.SequenciaInicial);
$("#SequenciaFinal").append(data.SequenciaFinal);
});
},
error: function (ex) {
alert('Falha ao buscar Proprietario.' + ex);
}
});
return false;
})
});
}
Fields that are not receiving values
<div class="form-group">
@Html.LabelFor(model => model.SequenciaInicial, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SequenciaInicial, new { htmlAttributes = new { @class = "form-control", disabled = "disabled" } })
@Html.ValidationMessageFor(model => model.SequenciaInicial, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SequenciaFinal, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SequenciaFinal, new { htmlAttributes = new { @class = "form-control", disabled = "disabled" } })
@Html.ValidationMessageFor(model => model.SequenciaFinal, "", new { @class = "text-danger" })
</div>
</div>