demo.js (403B)
1 var sys = require('util'); 2 var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; 3 4 var xhr = new XMLHttpRequest(); 5 6 xhr.onreadystatechange = function() { 7 sys.puts("State: " + this.readyState); 8 9 if (this.readyState == 4) { 10 sys.puts("Complete.\nBody length: " + this.responseText.length); 11 sys.puts("Body:\n" + this.responseText); 12 } 13 }; 14 15 xhr.open("GET", "http://driverdan.com"); 16 xhr.send();