這裏的test.html:無法獲取jQuery的阿賈克斯或.load執行腳本
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<script language=javascript>
$(document).ready(function() {
$("button").click(function() {
$.ajax({
url : "http://localhost:101/test2.html",
dataType : "html",
success: function(data){ alert(data); $("div").html(data); }
});
});
});
/*
$(document).ready(function() {
$.ajax({
url : "http://localhost:101/Scripts/testscript.js",
dataType : "script"
//success: function(data){ $("#inner-main").html(data); }
});
});
*/
</script>
<button> bleh </button>
<div> </div>
</body>
</html>
這裏的test2.html:
<script type=javascript>
alert("lock and load, outside!");
$(document).ready(function() {
alert("lock and load!");
});
</script>
<p>Hello, world </p>
我不能讓test1的加載TEST2,並在其中執行腳本。 我確實得到< p>(Hello World)在div中顯示。儘管如此,腳本不會執行。 我看到的唯一警報來自成功調用的函數。
我在做什麼錯?
的URL test1.html是http://localhost:101/test1.html
Javascript控制檯中的任何錯誤? –
不,不是在IE9(F12開發人員工具,腳本選項卡) – Anon
我試着運行這是IE9,歌劇11,Chrome瀏覽器。在其中任何一個都不起作用。 – Anon