root / trunk / code / projects / colonet / client / cgi / colonet.js @ 605
History | View | Annotate | Download (1.18 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", "http://roboclub9.frc.ri.cmu.edu/cgi-bin/colonet.cgi?command=" + data); |
18 |
} catch (e) {
|
19 |
document.getElementById("div3").firstChild.nodeValue = "Failed"; |
20 |
return;
|
21 |
} |
22 |
|
23 |
document.getElementById("div3").firstChild.nodeValue = "Sending Data ..."; |
24 |
try {
|
25 |
req.send(null);
|
26 |
} catch (e) {
|
27 |
document.getElementById("div4").firstChild.nodeValue = "Failed"; |
28 |
return;
|
29 |
} |
30 |
|
31 |
document.getElementById("div4").firstChild.nodeValue = "Done!"; |
32 |
return;
|
33 |
} |
34 |
|
35 |
|
36 |
function stateChanged () { |
37 |
document.getElementById("div5").firstChild.nodeValue = "State: " + req.readyState; |
38 |
document.getElementById("div6").innerHTML = req.responseText;
|
39 |
} |