Dojo xhr遇到问题?

发布于 2024-10-02 17:44:20 字数 1249 浏览 0 评论 0原文

我刚刚开始使用 Dojo,并且正在严格遵循“Hello World”教程。它在这里... http://www.dojotoolkit.org/reference-guide/快速入门/helloworld.html
我有一个像这样编码的 HTML 页面...

<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。

I am JUST starting with Dojo and am following the "Hello World" tutorial to the letter. It's here... http://www.dojotoolkit.org/reference-guide/quickstart/helloworld.html

I have an HTML page coded like this...

<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>

Allegedly this is supposed to popup the text from "response.txt" which is in the same directory (it's there and chmod-ed to 755. Clicking the button however does absolutely nothing. Anyone encounter this before?
Thanks! JW

Edit: Just in case this matters, I am using Ubuntu 10 with Firefox 3.6.12.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄凉少年不暖心 2024-10-09 17:44:20

我没有看到您在哪里定义了使用 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>

I don't see where you've defined the helloCallback method that calls alert using the data from response.txt. The page you linked in your question has more info on that.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文