P
P
password222020-02-28 14:39:14
AJAX
password22, 2020-02-28 14:39:14

Explain how to enable infinite scroll(ajax) on multiple pages?

Hello. Can't figure out how ajax scroll works on many sites?
After all, it turns out like this:

There are two files, one is index.php (it contains a page with a block where data is displayed and a script that sends a request for new data). The second file is data.php (it accepts the request and returns the data).

And it turns out that only one bundle of these two files can display blocks of a certain type (meaning with one class, id and styles).

How, then, to connect ajax scroll to multiple pages, if the block styles are different on different pages. And it turns out that you need to create your own data.php for each new style (new page)?

Please explain how this all works. Can't find any clear explanation on the internet.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pashenka, 2020-02-29
@password22

The request handler should return "clean" data, the common format for this is JSON. From which it follows that the markup of pages may vary somewhat if we are talking about the same data type (conditionally post). In this case, it does not matter, the data is simply substituted into a specific html template.
If we are talking about data of different types, then along with the request, you can send to the parameter type, which will tell the handler what type of data we are requesting, and that, by branching, will give the data we are interested in. That is, in other words, one common handler is enough.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question