$("#upd").click(() => {
let formdata = $("#formacad").serialize();
$.ajax({
type: "POST",
url: "/Js/AddUpdateMethod",
data: formdata,
success: function (result) {
location.reload();
}
}
)
})
as code shows this ajax request sending data to server updating record and reloading the page. this code works perfect(updating works) but i dont want to reload the page just want to update that section where these records foound.in case of any CRUD operation fetch record from db and show here without reload.how can do this.
for this section i have set some css seting i don't want to disturb them

Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 15, 2024, 1:02 AM EDT
You can achieve this by updating the success function of your AJAX call. Instead of reloading the page, you can update the specific section of the page with the new data. Here’s an example of how you can do it:
$("#upd").click(() => { let formdata = $("#formacad").serialize(); $.ajax({ type: "POST", url: "/Js/AddUpdateMethod", data: formdata, success: function (result) { // Assuming 'result' contains the updated record data // And '#recordSection' is the id of the section where the records are displayed $('#recordSection').html(result); } }) })In this code,
$('#recordSection').html(result);will update the HTML of the section with idrecordSectionwith the new data received from the server. Please replace#recordSectionwith the actual id of the section you want to update.Remember, the server should return the updated record data in a format that can be directly used to update the HTML of the section. If the data returned by the server is not in the correct format, you might need to process it before updating the HTML.
Thanks
Abhishek YadavRank #217 · 11.3K reputationPosted Mar 14, 2024, 1:35 AM EDT
$("#upd").click(() => { let formdata = $("#formacad").serialize(); $.ajax({ type: "POST", url: "/Js/AddUpdateMethod", data: formdata, success: function (result) { // Make another AJAX request to fetch the updated records $.ajax({ type: "GET", url: "/Js/FetchUpdatedRecords", success: function (updatedRecords) { // Update the section containing the records with the updated records $("#recordsSection").html(updatedRecords); } }); } }); });You can achieve this functionality by making an additional AJAX request to fetch and display the updated records without reloading the entire page. Here's how you can modify your code:
umair mohsinRank #3,092 · 463 reputationPosted Mar 14, 2024, 5:03 PM EDT
No dear it is not working i have tried this