我想跟隨在http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/modules-and-namespaces/creating-your-own-modul無法加載定製的Dojo模塊
我有道場的本地部署自定義模塊教程在http://localhost:8081/dojo-1.3.2/dojo/dojo.js 對於我創建了以下javascript文件在http://localhost:8081/dojo-1.3.2/explosive/space/Modulator.js我的自定義模塊:
dojo.provide("explosive.space.Modulator");
dojo.declare("explosive.space.Modulator",null,{
bob:1
});
在我的HTML頁面中我有以下幾點:
<script type="text/javascript" src="http://localhost:8081/dojo-1.3.2/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("explosive.space.Modulator");
</script>
而且當我在Firefox中拉起我的網站時,出現錯誤:
Error: Could not load 'explosive.space.Modulator'; last tried '../explosive/space/Modulator.js'
對我在做什麼有什麼錯誤的想法?
編輯:經過更多的測試後,它出現的代碼適用於IE8和IE8兼容模式,但不適用於Firefox,Chrome或Opera。
編輯2:我的HTML文件是在不同的域名,但我不認爲這應該有所作爲。在閱讀了Seth的評論(感謝Seth!)之後,我嘗試了兩種方法。
我有兩個tomcat實例,一個在端口8080上,另一個在端口8081上。我已經在兩個實例中放置了index.htm,並啓動它們。
http://localhost:8081/test/index.htm適用於FF和IE。 http://localhost:8080/test/index.htm在FF中無法正常工作,但在IE中可以正常工作。
顯示XmlHTTPRequests顯示FF正在打電話給「GET http://localhost:8081/dojo-1.3.2/explosive/space/Modulator.js」,由於某種原因,它將返回一個空響應。
這是我的index.htm的完整代碼,如果有任何幫助的話。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>Create Map</title>
<script type="text/javascript" src="http://localhost:8081/dojo-1.3.2/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("explosive.space.Modulator");
function init(){
var eludiumFuel36 = new explosive.space.Modulator();
alert(eludiumFuel36.bob);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
<h1>Hello World!</h1>
</body>
</html>
我在回覆中添加了一些內容到我的帖子中。順便說一句,謝謝。 – Phil 2009-09-17 17:31:59
好的,更新我的答案以反映新的信息。 – seth 2009-09-17 19:33:23