rob@77: var sys = require("util") rob@77: , assert = require("assert") rob@77: , XMLHttpRequest = require("../lib/XMLHttpRequest").XMLHttpRequest rob@77: , xhr; rob@77: rob@77: xhr = new XMLHttpRequest(); rob@77: rob@77: xhr.onreadystatechange = function() { rob@77: if (this.readyState == 4) { rob@77: assert.equal("Hello World", this.responseText); rob@77: this.close(); rob@77: runSync(); rob@77: } rob@77: }; rob@77: rob@77: // Async rob@77: var url = "file://" + __dirname + "/testdata.txt"; rob@77: xhr.open("GET", url); rob@77: xhr.send(); rob@77: rob@77: // Sync rob@77: var runSync = function() { rob@77: xhr = new XMLHttpRequest(); rob@77: rob@77: xhr.onreadystatechange = function() { rob@77: if (this.readyState == 4) { rob@77: assert.equal("Hello World", this.responseText); rob@77: this.close(); rob@77: sys.puts("done"); rob@77: } rob@77: }; rob@77: xhr.open("GET", url, false); rob@77: xhr.send(); rob@77: }