2010-11-12 73 views
0

我只是從Dojo開始,並且遵循這封信的「Hello World」教程。它在這裏... http://www.dojotoolkit.org/reference-guide/quickstart/helloworld.html
我有一個HTML頁面編碼是這樣的...
Dojo xhr獲取問題?

<html> 
<head> 
<title>Dojo: Hello World!</title> 

<!-- SECTION 1 --> 
<style type="text/css"> 
    @import "dojoroot/dijit/themes/tundra/tundra.css"; 
    @import "dojoroot/dojo/resources/dojo.css" 
</style> 
<script type="text/javascript" src="dojoroot/dojo/dojo.js" 
djConfig="parseOnLoad: true"></script> 

<!-- SECTION 2 --> 
<script type="text/javascript"> 
// Load Dojo's code relating to the Button widget 
dojo.require("dijit.form.Button"); 
</script> 
</head> 

<body class="tundra"> 
<button dojoType="dijit.form.Button" id="helloButton"> 
Hello World! 
<script type="dojo/method" event="onClick"> 
dojo.xhrGet({ 
    url: 'response.txt', 
    load: helloCallback, 
    error: helloError 
}); 
</script> 
</button> 
</body> 
</html> 

據稱這是應該彈出窗口「response.txt」,這是在同一目錄下的文本(這是有和chmod-ED爲755單擊該按鈕但是絕對沒有任何人之前遇到這種 感謝JW

編輯:?!萬一這個問題,我使用Ubuntu 10與Firefox 3.6.12

回答

1

我不是e您定義了使用response.txt中的數據調用alerthelloCallback方法。您在問題中鏈接的頁面上有更多信息。

<html> 
<head> 
<title>Dojo: Hello World!</title> 

<!-- SECTION 1 --> 
<style type="text/css"> 
    @import "dojoroot/dijit/themes/tundra/tundra.css"; 
    @import "dojoroot/dojo/resources/dojo.css" 
</style> 
<script type="text/javascript" src="dojoroot/dojo/dojo.js" 
djConfig="parseOnLoad: true"></script> 

<!-- SECTION 2 --> 
<script type="text/javascript"> 
// Load Dojo's code relating to the Button widget 
dojo.require("dijit.form.Button"); 
</script> 
<script> 
    function helloCallback(data,ioArgs) { 
     alert(data); 
    } 
    function helloError(data, ioArgs) { 
     alert('Error when retrieving data from the server!'); 
    } 
</script> 
</head> 

<body class="tundra"> 
<button dojoType="dijit.form.Button" id="helloButton"> 
Hello World! 
<script type="dojo/method" event="onClick"> 
dojo.xhrGet({ 
    url: 'response.txt', 
    load: helloCallback, 
    error: helloError 
}); 
</script> 
</button> 
</body> 
</html> 
+0

謝謝!我已標記你的答案。 Jeeez我有一個金髮的時刻。 JW – 2010-11-12 21:46:42