美文网首页
AJAX jQuery tab选项卡

AJAX jQuery tab选项卡

作者: code武 | 来源:发表于2017-12-20 14:50 被阅读0次

vardefault_content="";

$(document).ready(function(){

checkURL();

$('ul li a').click(function(e){

checkURL(this.hash);

});

//filling in the default content

default_content = $('#pageContent').html();

setInterval("checkURL()",250);

});

varlasturl="";

functioncheckURL(hash)

{

if(!hash) hash=window.location.hash;

if(hash != lasturl)

{

lasturl=hash;

// FIX - if we've used the history buttons to return to the homepage,

// fill the pageContent with the default_content

if(hash=="")

$('#pageContent').html(default_content);

else

loadPage(hash);

}

}

function loadPage(url)

{

url=url.replace('#page','');

$('#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');

}

}

});

}

相关文章

网友评论

      本文标题:AJAX jQuery tab选项卡

      本文链接:https://www.haomeiwen.com/subject/hmugwxtx.html