I am doing dynamic dropdown menu but I have problem to keep it after page refreshing.
I use maybe old way and if user choose some option in first select, I am sending ajax request to php page and show options on current page in second select.
I store all values of fields via localstorage, but problem is that selects (inputs) added dynamically by ajax are not visible on load of page.
So I decide to send my data to php page directly in request sent after refreshing.
My code is something like this:
$(window).on('load', function() {
// Send cat id to add.php to change select options in html according to cat id
$.ajax({
url: 'add.php',
headers: {"X-Test-Header": "test-value"}
});
})
Is there some good way how to do that? Or should I for ex totaly change logic and use dynamically dropdown menu just with JS? Need to load tbale data form db to object.
Thanks