$("#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 MakwanaPosted Mar 15, 2024, 5:02 AM
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:
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
umair mohsinPosted Mar 14, 2024, 9:03 PM
No dear it is not working i have tried this
Abhishek YadavPosted Mar 14, 2024, 5:35 AM
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: