Dojo is a Java Script toolkit. This is a minimal HTML page which uses a widget and talks to the server. This is based on the Dojo tutorial at
JotSpot.
<html>
<head>
<title>Dojo: Hello World!</title>
<script type="text/javascript" src="/js/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("dojo.event.*");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.Button");
function helloPressed()
{
dojo.io.bind({
url: '/cgi-bin/HelloWorldResponsePOST.rb',
handler: helloCallback,
formNode: dojo.byId('myForm')
});
}
function init()
{
var helloButton = dojo.widget.byId('helloButton');
dojo.event.connect(helloButton, 'onClick', 'helloPressed')
}
function errorCallback(type, error)
{
alert(error)
}
function helloCallback(type, data, evt)
{
if (type == 'error')
alert('Error when retrieving data from the server!');
else
alert(data);
}
dojo.addOnLoad(init);
</script>
</head>
<body>
<button dojoType="Button" widgetId="helloButton">Hello World!</button>
<br>
<form id="myForm" method="POST">
Please enter your name: <input type="text" name="name">
</form>
</body>
</html>