Need help with Ajax requests with Kirby

This works! It will take a lot of tweaking to fit my layout, but it will do.

I had to put the ajax conditional for header/footer inside the snippet itself, it wasn’t working if put in the template.

One thing: What is the easiest way to prevent the content to load on top of the previous?

There need to be a line of code to destroy/unload the previous content after I click in a second url

Thank you