In my app I have an input form that uses a post route to find all information on an item based on a project ID. When you search for the project ID you can update and delete each field that is returned, but after you do either one of those actions the page, reloads, and you lose the project you were working on. I want to set the project ID into local storage when you first submit the page to find the information so that way when you edit or delete and the page refreshes it will make an AJAX call with the stored project ID in localstorage and then pull up the same project.
$("#formData").on('submit', () => {
localStorage.setItem('search', $('#search').val());
});
Right now I'm getting a 500 internal server error. If anyone has an idea on how this can be done, I would greatly appreciate it!
window.onload = () => {
const searchedId = localStorage.getItem('search')
if (window.location.href.match('/find')) {
$.ajax({
url: '/find',
type: 'POST',
data: searchedId,
})
}
};