Load part of a page using ajax and jquery but show GET variable in url

To show you what I want to do, you just need to visit gmail. When you click on the inbox, the url is updated to this tab "tab = mm #" and the only part of the page being refreshed is the most part in which your emails are what google calls div.lm How is this possible? How much do they use cache or do they use javascript command which I don't know about?

What I want to do, I have a page with two different tabs.

<div id="navcontainer"> <ul id="navlist"> <li id="active"><a href="#" id="current">Products</a></li> <li><a id="prreq" onclick="show()" >Requests</a></li> </ul> </div> <div class="container"></div> 

When users go, for example. cart.php they go to the first tab. When users click on the second tab, the js function is launched, which calls the cart.php file? Rq = r, and the results are displayed in the div container. (I know that at the moment I have a post)

 function show(){ var prstr= ".container"; var data= { rq: "r" }; $.ajax({ type: 'POST', url: "cart.php", data: data, success: function(data1) { $(prstr).html(data1); } }); 

}

What I want is when a user refreshes a page that is still in cart.php? rq = r, and no need to click on the tab again. I would appreciate any help. if you need more information, please let me know Thank you in advance.

+4
source share
1 answer

They simply access the hash component of the URL through location.hash . When the hash changes, they should have some logic that determines which part of the page is being updated.

+3
source

All Articles