![](/img/trans.png)
[英]jQuery.load() is loading the page, but the embed javascript inside the loaded page is giving Method Not Allowed
[英]How to run javascript code included in a page loaded with jquery.load()
我正在使用jquery.load()
動態加載頁面的各個部分。 但我希望包含的部分都包含HTML並能夠執行腳本。 但是簡單
<script>
alert("hello");
</script>
AJAX插入時不會運行。是否有另一種方式來動態加載內容以使腳本能夠運行,或手動運行包含的內容中的腳本? 在這種情況下,我依賴jquery.load
僅包括已加載頁面中特定選擇器的方式。
FWIW我正在使用Jquery 1.4.2。
嘗試將加載頁面中的腳本更改為:
<script>
$(function(){
alert("hello");
});
</script>
這應該使其在加載時運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.