P
P
picka2020-04-22 19:19:23
JavaScript
picka, 2020-04-22 19:19:23

Insert page url when Ajax loading a piece of content, but not following it?

Have this code

$(document).ready(function() {

        $('#swup a').click(function(){

        var toLoad = $(this).attr('href')+' #article';
        $('#article').hide('fast',loadContent);
        function loadContent() {
        $('#article').load(toLoad,'',showNewContent())
        }
        function showNewContent() {
        $('#article').show('normal');
        }
        return false;

        });
        });

This code looks at all a-links in the block, and tracks clicks on them, when clicked, pulls out from the page to which the link refers all the content located in the block with id="article" and embeds on the same page in the block with id="article" "everything works well, the only problem is that the link does not change, but I would like the link to be replaced with the link of the page from which the content was pulled.
All the solutions that I found on this topic were based on the fact that the url was inserted with #, and this is not suitable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2020-04-22
@AndryG

the only problem is that the link does not change, but I would like the link to be replaced with the link of the page from which the content was pulled.

If a link here means a link to the current document in the address bar of the page, then (immediately write about it, and not link-link-link) to help you history - a browser gadget that changes that very link controls the history in the address bar :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question