javascript - php script not showing through my ajax loaded content -
so have index.php file uses ajax loading contents .php file within same directory. reason when click link menu , loaded in ajax, php script news panel isn't executing, or isn't visible.
demo link: http://www.michaeldylanedwards.co.uk/#archives
direct link: http://www.michaeldylanedwards.co.uk/archives.php
php script
<?php $category = "8"; $template = "archives"; include("admin/show_news.php"); ?>
here codes ajax loaded content;
load_page.php
<?php if(!$_post['page']) die("0"); $page = $_post['page']; if(file_exists($page.'.php')) echo file_get_contents($page.'.php'); else echo 'there no such page!'; ?>
script.js
var default_content=""; $(document).ready(function(){ checkurl(); $('ul li a').click(function (e){ checkurl(this.hash); }); //filling in default content default_content = $('#pagecontent').html(); setinterval("checkurl()",250); }); var lasturl=""; function checkurl(hash) { if(!hash) hash=window.location.hash; if(hash != lasturl) { lasturl=hash; // fix - if we've used history buttons return homepage, // fill pagecontent default_content if(hash=="") $('#pagecontent').html(default_content); else loadpage(hash); } } function loadpage(url) { url=url.replace('#',''); $('#loading').css('visibility','visible'); $.ajax({ type: "post", url: "load_page.php", data: {page: url}, datatype: "html", success: function(msg){ if(parseint(msg)!=0) { $('#pagecontent').html(msg); $('#loading').css('visibility','hidden'); } } }); }
any appreciated!
so, when on #archives page blank, clicking around on top links #home, #blog etc work, im assuming expected behaviour.
however, when clicking on #contact , #social, breaks site.. because whatever ajaxpage()
function doing (you haven't included in above js) removing #pagecontent
loadpage()
function requires insert content.
(i believe ajaxpage()
whacking it's response output content, removing inner #pagecontent
)
Comments
Post a Comment