summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/manual/ajax.html
blob: be038ad470d8853b113c9015bd452437477b366d (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
39
40
41
42
43
44
45
46
47
48
49
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>XHR Acceptance Test</title>
    <script src="../../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        var url = "ajax.txt";
        function sendSynchronous(){
            var request = OpenLayers.Request.GET({
                url: url,
                async: false,
                callback: function() {
                    document.getElementById('send_sync').value += 'request completed\n';
                }
            });
            document.getElementById('send_sync').value += 'other processing\n';
        }
        function sendAsynchronous(){
            var request = OpenLayers.Request.GET({
                url: url,
                callback: function() {
                    document.getElementById('send_sync').value += 'request completed\n';
                }
            });
            document.getElementById('send_sync').value += 'other processing\n';
        }
        function sendAndAbort(){
            var request = OpenLayers.Request.GET({
                url: url,
                callback: function() {
                    document.getElementById('send_sync').value += 'never called\n';
                }
            });
            request.abort();
            document.getElementById('send_sync').value += 'other processing\n';
        }

        </script>
    </head>
    <body >
        <button onclick="sendSynchronous()">synchronous</button>
        expected output: "request completed" then "other processing"<br />
        <button onclick="sendAsynchronous()">asynchronous</button>
        expected output: "other processing" then "request completed"<br />
        <button onclick="sendAndAbort()">send and abort</button>
        expected output: "other processing" (and not "never called")<br />
        <textarea id="send_sync" rows="6"></textarea><br />
        <button onclick="document.getElementById('send_sync').value = ''">Clear</button>
  </body>
</html>