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 6745389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:11:55+00:00 2026-05-26T12:11:55+00:00

I have been racking my brain and searching google for almost the whole day

  • 0

I have been racking my brain and searching google for almost the whole day on why this will not work. As an experiment for improving my own site I was checking out a tutorial here http://tutorialzine.com/2009/09/simple-ajax-website-jquery/ most importantly the ajax/jquery section.

Basically, that tutorial’s POST works with page numbers, however I have been trying to convert it to use page names instead. So it would take #!home (hashbangs for implementing google compatibility later) from an href and php could parse it as “home.html” and load that into the content div. For reasons beyond me, it just will not work. I’ll post the relevant sections of code I have attempted to modify in my favour:

From the javascript loader (only the end section which I modified):

var datastring=url.replace('#!','');    //strip the #page part of the hash and leave only the page number

$('#loading').css('visibility','visible');  //show the rotating gif animation

$.ajax({    //create an ajax request to load_page.php
    type: "POST",
    url: "load_file.php",
    data: datastring,   //with the page number as a parameter
    dataType: "html",   //expect html to be returned
    async: false,
    success: function(msg){

        if(parseInt(msg)!=0)    //if no errors
        {
            $('#content').html(msg);    //load the returned html into pageContet
            $('#loading').css('visibility','hidden');   //and hide the rotating gif
        }
    }

});

And the entire php file:

    <?php 
$url = $_POST['datastring'];

if(file_exists(''.$url.'.html'))
echo file_get_contents(''.$url.'.html');

else echo 'There is no such page!';

?>

I wanted to learn on my own and figure this out but honestly I don’t get it :/ There’s no cross domain problem as far as I can tell. Anybody know what I’m missing?
Figured I’d ask here since it’s likely to be more traveled than that tutorial’s site, although if I find a solution I’ll go over there and post it in the comments too so others may avoid my pain. XD

  • 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-26T12:11:56+00:00Added an answer on May 26, 2026 at 12:11 pm

    You need to pass your POST data as a key,value pair.

    Try changing your data to this:

    data: "datastring="+datastring
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been racking my brain (not hard to do) trying to figure this
I have been racking my brain over this all day today. I have the
I have been racking my brain all morning with this. I am using Eclipse
I've been racking my brain with this one. I have two arrays: Array 1
I have been racking my brain on this one for hours now and I
I have been racking my small brain for ages now, so can this be
I have been racking my brain around this for a few hours. Basically I
Morning, I have been racking my brain and eyes for the past 4 days
In trying to parse a date, I have been racking my brain for hours:
I've been racking my brains over this for a while and have resorted to

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.