A
A
Anton Shelestov2021-05-08 09:52:48
AJAX
Anton Shelestov, 2021-05-08 09:52:48

How to properly set up content loading in ajax filter?

Hello!

Please tell me, I ran into a problem with the ajax filter on the page.

For example, on the page there is a block with a filter, clicking on some checkbox sends a request to the server and the server returns an html code piece of the product list. This html is respectively inserted into the content of the page. There are no problems with this, everything works.

The problem appears when if you leave the tab (do not close the site) and do not go to it for a long time, then how to go to it on the page is shown just the html response from the server in its raw form,

609634ce5176d959966978.png

how is it possible? Has anyone experienced this?

By the way, if it's important, when I change the filter, the url changes

if ('URLSearchParams' in window) {
            if(Object.keys(arr).length > 0) {
                var newRelativePathQuery = _form.data('url') + '?' + $.param(arr);
            } else {
                var newRelativePathQuery = _form.data('url');
            }
            history.pushState(null, '', newRelativePathQuery);
        }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question