I have a table in cshtml with each td contains id insted store from model
I want to store ajax response json and fill the data (td which contain id from ajax response)
My problem is when my controller is success send data , why the value of each td with id with filled up with data object response
<table class="table table-vcenter card-table table-bordered">
<tr>
<th class="table-light">Well Name</th>
<td id="_wellname">@Model.WellName</td>
<th class="table-light">Field</th>
<td id="_field">@Model.Field</td>
<th class="table-light">Platform</th>
<td id="_platform" colspan="3">@Model.Platform</td>
</tr>
</table>
<script>
$(document).ready(function () {
$('#well_id').on('change', function () {
var selectedwell = $('#well_id').val();
//alert(selectedwell);
$.ajax({
type: 'GET',
url: '/Home/GetIndividualWell',
data: { uwi: selectedwell },
contentType: 'application/json; charset=utf-8',
datatype: 'json',
success: function (data) {
if (data !== null) {
//@Model.WellName = data.WellName;
$.each(data, function (i, obj) {
$('#_wellname').val(obj.WellName);
$('#_field').val(obj.Field);
$('#_platform').val(obj.Platform);
//alert(obj.WellName);
});
}
else {
alert("data not found");
}
},
error: function (err) {
alert(err);
}
});
});
});
</script>
public async Task<JsonResult> GetIndividualWell(string uwi)
{
var rs = await _iwell.GetWellData(uwi);
return Json(new { data = rs });
}
Thank you