summaryrefslogtreecommitdiff
path: root/data/index.html
blob: abe6fdbfaa6bef087f4128ec4b7515115e8e708a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>Javascript Example</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>    
    <script src="prototype.js" type="text/javascript"></script>
  </head>

  <body>
    <h1>Fetching object from server</h1>
    <div id="list">
      Wait...<br/>
      <noscript><p>Switch on Javascript!</p></noscript>
    </div>
    <script type="text/javascript">
    <!--
    function pollJSON() {
      new Ajax.Request('/json',
        {
          method: 'get',
          onSuccess: function(transport) {
            var response = transport.responseText || "no response text";
            response = eval("(" + response + ")");
            var text = "";
            for (var k in response) {
              text = text + "<b>" + k + "</b>: " + response[k] + "<br/>"
            }
            $("list").update(text);
          },
          onFailure: function() { alert('Something went wrong...') }
        });
    }
    new PeriodicalExecuter(pollJSON, 1);
    -->
    </script>
  </body>
</html>