2013-04-20 64 views
0

我试图加载一个包含javascript链接的div到另一个页面上的另一个div(http://www.thebigkerbang.com/brand-storytellers/clients/xour-clients.html)和load()。我知道load()去掉脚本标记,但是我对$ .getscript有些困惑。我可以加载分区罚款,因为我可以在代码检查器中看到它。包含脚本的jQuery加载()div

加载该网页上的DIV:

<div id="beautific_hype_container" style="position:relative;overflow:hidden;width:700px;height:500px;"> 
    <script type="text/javascript" charset="utf-8" src="beautific.hyperesources/beautific_hype_generated_script.js?10913"></script> 
    </div> 

到DIV从这个页面:

<div class = "edgeContent"></div> 

有:

$('document').ready(function(){ 
    $(".beautific").click(function(){ 
    $(".edgeContent").load('beautific/beautific.html #beautific_hype_container', function() { 
    $.getScript('beautific/beautific.hyperesources/beautific_hype_generated_script.js?10913'); 
     }); 
     }); 
    }); 
+0

你怎么感到困惑?什么不起作用? – fredrik 2013-04-20 14:45:02

+0

谢谢Fredrik。这仍然只加载 '

'并且去掉脚本。 – 2013-04-20 15:31:31

+0

奇怪的是,我自己使用这个方法,脚本没有被过滤掉。然后再次 - 我没有用'src'引用脚本,我把它放在了内联中。 – fredrik 2013-04-20 15:33:46

回答

0

我会继续$.ajax()调用做到这一点:

$('document').ready(function(){ 
    $(".beautific").click(function(){ 
    $.ajax({ 
     url: "beautific/beautific.html #beautific_hype_container", 
    }).done(function (data) { 
     $(".edgeContent").html(data); 
    }); 
    }); 
}); 

这样,你的脚本标签也不会被过滤掉。