napstyr maceda
napstyr maceda

Reputation: 179

How can I load the entire page using PJAX

Is it possible to load the entire page using PJAX and change the browser's page url?

My purpose is to prepare first the response to make sure that it would be loaded without refreshing the page in a long time after clicking in the menu-page-link or execute a javascript function.

I tried using PJAX but the one that provides a response data for the selected element to load where the request has to display.

Like:

$('a').pjax("#container", { fragment: "#container" });

I want and I tried:

$('a').pjax({url:"new-page.html"});

But it didn't work.

I'll appreciate your help and suggestions. Thank you!

Upvotes: 1

Views: 1754

Answers (2)

Nikhil Kumar
Nikhil Kumar

Reputation: 134

Yes it is very much possible using jquery PJAX plugin , you can keep the header footer static and change the body content using PJAX , and yes it will change the url too along with browser history stack i.e. almost making it like a normal navigation, except that page wouldn't be refreshed. But the container needs to be same in both the urls. You can try :

$(document).pjax('a', '#pjax-container')

Upvotes: 3

Nhu Trinh
Nhu Trinh

Reputation: 13956

You can load page via ajax but you cannot change page url, when you change it, it will automatic redirect to that address. This prevent phishing page, fake url.... But why you need to load page via ajax then change the url, why don't just change the url?

Upvotes: 0

Related Questions