Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 933557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:51:11+00:00 2026-05-15T20:51:11+00:00

Now here is my situation: I’m making a CMS. When links are clicked, i

  • 0

Now here is my situation: I’m making a CMS. When links are clicked, i would like the pages to load dynamically using Ajax. The problem in the links!

The only way to change the address in the address bar real-time is to use anchor tags. But PHP doesn’t get the anchor tags, thus I can’t load page content on site load using PHP.
And if i were to load the pages using a query string, the query string couldn’t be updated in the address bar at the click of a link, since that would reload the page.

I suppose Javascript could check the address, save the anchor tag in a cookie and reload the page, but I’d rather not have to go to such lengths.

Does anyone know a solution to this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T20:51:12+00:00Added an answer on May 15, 2026 at 8:51 pm

    There was a similar question not so long ago, and I came up with the following solution.

    Your urls should point to real pages in order to get it work in for js disabled users. The click handlers should handle ajax requests. Hash should contain the url, and a part like &ajax to indicate the type of the request.

    If the request is from ajax simply send the content. If it is not, wrap the content into header and footer to respond with a full site.

    Urls should work with linking to ajax generated hashes and using them as links. The whole idea is basically mimics the kind of behavior you can see on facebook.

    Javascript

    // click handler for ajax links
    function goToWithAjax(hash) {
      hash = hash.href ? hash.getAttribute("href", 2) : hash;
      ajax( hash, function( response ) {
        document.getElementById("content").innerHTML = response;
      });
      hash = ("#!/" + hash).replace("//","/");
      window.location.hash = hash;
      return false;
    }
    

    .htaccess

    auto_prepend_file = "prepend.php"  
    auto_append_file  = "append.php"  
    

    prepend

    $url   = $_SERVER['REQUEST_URI'];
    $parts = explode('#!', $url);
    $hash  = isset($parts[1]) ? $parts[1] : false;
    
    // redirect if there is a hash part
    if ($hash) {
      header("Location: $hash");
    }
    
    // find out if it's an ajax request
    $ajax = strstr($url, "&ajax");
    
    // we need header if it's not ajax
    if (!$ajax) {
      get_header();
    }
    

    append

    // we need footer if it's not ajax
    if (!$ajax) {
      get_footer();
    }
    

    get_header()

    function get_header() {
    
    echo <<< END
    <html>
    <head></head>
    <body>
    <div id="page">
      <div id="header">
        <div id="logo"></div>
        <ul id="nav">menu...</ul>
      </div>
      <div id="content">
    END;
    
    }
    

    get_footer()

    function get_footer() {
    
    echo <<< END
      </div> <!-- end of #content --->
      <div id="footer">(c) me</footer>
    </div> <!-- end of #page --->
    </body>
    </html>
    END;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the situation - I've got a shell that loads an external .swf. Now,
I've been reading things here and there for a while now about using an
.NET developers out there! Need your opinion here! I am now using Visual Assist
Now I must be missing something here, as this seems a very basic issue
Here's a question that's been haunting me for a year now. The root question
last time I asked how to populate a data structure here . Now I
Now that LINQ to SQL is a little more mature, I'd like to know
Here the Situation . I am having 2 million records in table . Just
I have a situation here where I need to distribute work over to multiple
Here's my situation. I've just started a new job and I've inherited an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.