2013-04-20 63 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); 
    }); 
    }); 
}); 

這樣,你的腳本標籤也不會被過濾掉。