forked from borisreitman/CrossXHR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
53 lines (47 loc) · 1.5 KB
/
Copy pathexample.html
File metadata and controls
53 lines (47 loc) · 1.5 KB
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
50
51
52
53
<HTML><HEAD><TITLE>CrossXHR demo</TITLE></HEAD><BODY>
<script src="crossxhr.js"></script>
</HEAD><BODY>
<script>
var request;
function callback() {
if (request.readyState == 4) {
try {
if (request.status != 200) {
alert('error detected 1');
} else {
// ok, process...
alert("got data: "+request.responseText);
}
} catch(e) {
alert('error detected 2');
}
}
}
function test_get() {
request = new CrossXHR();
request.onreadystatechange = callback;
request.open('GET', 'http://www.pliantdev.com/support/test.xml');
request.send();
}
function test_bad() {
request = new CrossXHR();
request.onreadystatechange = callback;
request.open('GET', 'http://very.bad.url.com/x.xml');
request.send();
}
</script>
<H1> Cross XHR demo </H1>
<EM> This demo requires flash to be installed in your browser </EM>
<p>
Click the "test cross domain ajax" button to load <a href="http://www.pliantdev.com/support/test.xml">http://www.pliantdev.com/support/test.xml</a> using an AJAX call.
</p>
<input type=button onclick="test_get()" value="test cross-domain ajax">
<p>
Click the "test error detection" button to attempt to load an invalid URL "http://www.pliantdev.com/support/does-not-exist.xml"
</p>
<input type=button onclick="test_bad()" value="test error detection">
<p>
It is instructive to view the HTML source of this page.
More information can be found at the <a href="http://code.google.com/p/crossxhr/">CrossXHR homepage</a>.
</p>
</BODY></HTML>