K
K
Kornely2022-01-10 18:10:26
AJAX
Kornely, 2022-01-10 18:10:26

How to make pagination navigation stay inside ajax page?

The page is loaded on the current page on click:

$(document).ready(function () {
    $("#show").click(function () {
          $("#container").empty(),$("#container").append($("<div></div>").load("page.html"));
    });	
});

This page.html has pagination. But when you go to the second or any other page, that page is already loaded completely.

But it is necessary that other pages continue to load in this block, while the address bar would not change. Can ajax

do it ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2022-01-11
@zkrvndm

Load the data not in a div but in an iframe , then all pagination will take place purely inside the iframe without affecting the main page.

$(function () {
    $("#show").one('click', function () {
          $("#container").html('<iframe src="page.html"></iframe>');
    });	
});

The height and width of the frame can be set either fixed via css or dynamically edited using JS. With the correct height and width, the frame borders are not rendered or visible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question