demo.js 411 B

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