First of all, I am developing a project where I use a crud operations with .net core. But how should I do the update? First code; Function that opens the modal of the retrieved data. Data is being pulled successfully.
Second code; The area where the button is located in ajax. Code in the third field; I will update the ajax function. I don’t know how to use this. The code in the fourth field; The routing found in the index. The code in the fifth field; update controller area, which I haven’t been able to do yet.
Honestly, I’m pretty new to ajax. How do I do this?
function upNews(pid) {
var table = $('#kt_datatable').DataTable();
secilenDeger = table.data().filter(x => x.Id == pid)[0];
$('#idd').val(secilenDeger.Id);
$('#nm').val(secilenDeger.Name);
$('#dsc').val(secilenDeger.Description);
$('#grs').val(secilenDeger.DetayImage);
$('#dt').val(secilenDeger.Data);
$('#GexampleModalSizeLg').modal('show');
}
<a href="javascript:" class="btn btn-sm btn-clean btn-icon" onclick="upNews('+ data +')" title="Edit details">
<i class="la la-edit"></i>
function updateNews() {
$.ajax({
type: "POST",
url:hst3,
dataType: "json",
data: {
"table": {
"name": $('#Name').val(),
}
},
})
}
var hst3 = "@Url.Action("EditNews", "Haberler")";
[HttpPost]
public Task<JsonResult EditNews(News n)
{
var sonuc = _adminService.addnws(newss);
return Task.FromResult(Json(sonuc));
}