php - Ajax load contents and append related urls

742

I am trying to use Ajax in a Project.

The Idea is when i click a Tab, The Relevant Data should load according to that Tab.

But it also should append the Url on address bar of current form that i am in.

Let Suppose i clicked the ERP Tab, so then ERP Divs should load inside the page but also the relative url should also show e-g www.mydomain.com\erp

i know about .load function, but with it it dont update the url on address bar. plus data will be coming from different files.

Also Left Side Menus will be coming from Database on Role Base.

i am using codeigniter in this project

i want to have Url functionality as it will be easy for user to access that page directly with the complete url plus it also gives bookmark advantage too..

Here is the screenshot for more convenience. enter image description here

581

Answer

Solution:

AFAIK you can't change the actual URL without a page reload.

You'll have to use 'jquery-address' library. Check out https://github.com/asual/jquery-address

361

Answer

Solution:

I would do two different things here:

  1. To change the URL dynamically without page load, use the new history.pushState() method. If you are supporting older browsers, history.js is essentially the same API that falls back to a hashtag method. Note that these URLs are not accessible from the outside. Thus:

  2. When a user travels to one of those URLs, default the open tab to whichever one you are trying to. You will have to capture the intended route and work some javascript magic on it.

People are also looking for solutions to the problem: Cannot return correct result from SQL query in PHP

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.