Jane Wilkie
Jane Wilkie

Reputation: 1743

Dojo xhrGet problem?

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.

Upvotes: 0

Views: 1702

Answers (1)

user506069
user506069

Reputation: 781

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>

Upvotes: 1

Related Questions