I have a rather simple JS code, that based on user selected category(that is loaded trough JS function that again calls ajax) calls other JS functions, that also calls JS function and Ajax and so on. What I wanted is that trough usage of cookies, user selected categories are saved on page refresh.
The problem Im facing is, that on refresh, no mather how i call those functions with values i got from cookies (basically the same as user clicks, but in rapid succesion), they only load the ajax, but dont hide the elements that is done before ajax call (maybe because previous functions hasnt updated DOM yet, so there`s nothing to hide).
Basically I need a way to wait for DOM load, and other JS functons/ajax calls and only then call the function.