You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
680 B
33 lines
680 B
2 years ago
|
var sys = require("util")
|
||
|
, assert = require("assert")
|
||
|
, XMLHttpRequest = require("../lib/XMLHttpRequest").XMLHttpRequest
|
||
|
, xhr;
|
||
|
|
||
|
xhr = new XMLHttpRequest();
|
||
|
|
||
|
xhr.onreadystatechange = function() {
|
||
|
if (this.readyState == 4) {
|
||
|
assert.equal("Hello World", this.responseText);
|
||
|
runSync();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
// Async
|
||
|
var url = "file://" + __dirname + "/testdata.txt";
|
||
|
xhr.open("GET", url);
|
||
|
xhr.send();
|
||
|
|
||
|
// Sync
|
||
|
var runSync = function() {
|
||
|
xhr = new XMLHttpRequest();
|
||
|
|
||
|
xhr.onreadystatechange = function() {
|
||
|
if (this.readyState == 4) {
|
||
|
assert.equal("Hello World", this.responseText);
|
||
|
console.log("done");
|
||
|
}
|
||
|
};
|
||
|
xhr.open("GET", url, false);
|
||
|
xhr.send();
|
||
|
}
|