I get the extremely annoying and mysterious “1” displayed on the bottom right of each page from what I assume is an error somewhere in the following ajax request and php code. The section marked as php downloader is a separate page with this name. html is just li with hash tags and rel = "ajax"
$(document).ready(function () { //Check if url hash value exists (for bookmark) $.history.init(pageload); //highlight the selected link $('a[href=' + document.location.hash + ']').addClass('selected'); //Search for link with REL set to ajax $('a[rel=ajax]').click(function () { //grab the full url var hash = this.href; //remove the # value hash = hash.replace(/^.*#/, ''); //for back button $.history.load(hash); //clear the selected class and add the class class to the selected link $('a[rel=ajax]').removeClass('selected'); $(this).addClass('selected'); //hide the content and show the progress bar //$('#content').hide(); $('#loading').show(); //run the ajax getPage(); //cancel the anchor tag behaviour return false; }); }); function pageload(hash) { //if hash value exists, run the ajax if (hash) getPage(); } function getPage() { //generate the parameter for the PHP var data = 'page=' + encodeURIComponent(document.location.hash); $.ajax({ url: "loader.php", type: "GET", data: data, cache: false, success: function (html) { //hide the progress bar $('#loading').hide(); //add the content retrieved from ajax and put it in the #content div $('#content').html(html); //display the body with fadeIn transition $('#content').fadeIn('fast'); SyntaxHighlighter.highlight(); } }); } </script> <? switch($_GET['page']) { case '#code' : $page = include ($_SERVER['DOCUMENT_ROOT'].'/mysite/code.php'); break; case '#design' : $page = include ($_SERVER['DOCUMENT_ROOT'].'/mysite/design.php'); break; case '#illustration' : $page = include ($_SERVER['DOCUMENT_ROOT'].'/mysite/illustration.php'); break; case '#writing' : $page = include ($_SERVER['DOCUMENT_ROOT'].'/mysite/writing.php'); break; case '#links' : $page = include ($_SERVER['DOCUMENT_ROOT'].'/mysite/links.php'); break; case '#about' : $page = include ($_SERVER['DOCUMENT_ROOT'].'/mysite/about.php'); break; } echo $page; if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) ) { } else { header("Location: /mysite/#/index"); } ?>
source share