root / trunk / code / projects / colonet / client / cgi / colonet.js @ 606
History | View | Annotate | Download (1.17 KB)
1 |
|
---|---|
2 |
|
3 |
var req;
|
4 |
|
5 |
function send (data) { |
6 |
document.getElementById("div1").firstChild.nodeValue = "Creating XMLHttpRequest Object ..."; |
7 |
try {
|
8 |
req = new XMLHttpRequest();
|
9 |
req.onreadystatechange = stateChanged; |
10 |
} catch (e) {
|
11 |
document.getElementById("div2").firstChild.nodeValue = "Failed"; |
12 |
return;
|
13 |
} |
14 |
|
15 |
document.getElementById("div2").firstChild.nodeValue = "Opening connection ..."; |
16 |
try {
|
17 |
req.open("GET",
|
18 |
"http://128.2.99.176/cgi-bin/colonet.cgi?command=" + data);
|
19 |
} catch (e) {
|
20 |
document.getElementById("div3").firstChild.nodeValue = "Failed"; |
21 |
return;
|
22 |
} |
23 |
|
24 |
document.getElementById("div3").firstChild.nodeValue = "Sending Data ..."; |
25 |
try {
|
26 |
req.send(null);
|
27 |
} catch (e) {
|
28 |
document.getElementById("div4").firstChild.nodeValue = "Failed"; |
29 |
return;
|
30 |
} |
31 |
|
32 |
document.getElementById("div4").firstChild.nodeValue = "Done!"; |
33 |
return;
|
34 |
} |
35 |
|
36 |
|
37 |
function stateChanged () { |
38 |
document.getElementById("div5").firstChild.nodeValue = "State: " + req.readyState; |
39 |
document.getElementById("div6").innerHTML = req.responseText;
|
40 |
} |