2011-08-04 45 views
1
window.onload= function(){ 
    var page = window.location.hash; 
    if(window.location.hash != ""){ 
     page = page.replace('#page:', ''); 
     getdata('src/'.page); 
    } 
} 

窗口加载后,我希望页面在URL中查看,看看是否有#设置,如果是,我想抓住页面并将其显示在DIV中。例如,一个链接将是<a href="page.php#page:contact.php">link</a>。因此,当点击链接时,页面会认为并抓取contact.php中的数据,并将其放入div中。但现在,这不起作用。没有错误,没有警告,没有任何东西。请帮助?谢谢!从URL获取特定页面并通过AJAX获取数据

编辑:GETDATA:

function getdata(file){ 

    openloading(); // loading message 

    $('#content').fadeOut('slow', function() { // Content is the div where all the content must be in 
     $.get(file, function(data) { 
      $('#content').html(data); 
      $('#content').fadeIn('slow'); 
     }) 
    }) 

    updateusersonline(); 
} 

而且updateusersonline()直接太:

function updateusersonline(){ 
    $.get('src/usersonline.php', function(data3) { 
     $('#usersonline').html(data3); 
    }) 
+0

什么是你的'的GetData()'函数是什么样子? – Lance

+3

'getdata('src /'。page);'应该是'getdata('src /'+页面);' – Joe

+0

@Lance添加了! – Thew

回答

1

getdata('src/'.page);应该getdata('src/' + page);