2011-08-05 72 views
1

我有一个外部页面添加到一个div,如果我写这它的工作原理jQuery的 - .load不工作

$(document).ready(function(){ 
$('div[align=center]:eq(1)').append('<br /><a class="linkone" href="#">Link 1</a><div class="testing"></div>'); 

$(".linkone").click(function(event) { 
      event.preventDefault();    
      var thelink = $('.blockhead a').filter('a[href^="http://site.com/gallery/photo/showgallery.php?cat="]').attr('href'); 
      $(".testing").load("http://site.com/gallery/photo/showgallery.php?cat=1001 .forumrow table"); 
      }); 
}); 

但如果我写这篇文章它不会工作

$(document).ready(function(){ 
$('div[align=center]:eq(1)').append('<br /><a class="linkone" href="#">Link 1</a><div class="testing"></div>'); 

$(".linkone").click(function(event) { 
      event.preventDefault();    
      var thelink = $('.blockhead a').filter('a[href^="http://site.com/gallery/photo/showgallery.php?cat="]').attr('href'); 
      $(".testing").load("thelink .forumrow table"); 
      }); 
}); 

哪有在.load后插入一个变量?

+0

什么是您的网站的地址,因为如果不是site.com不同的,那么有没有办法通过AJAX –

回答

9
$(".testing").load(thelink+" .forumrow table"); 
+0

是加载它!它现在有效!非常感谢! – user827253