【JS】シンプルAJAXテスト
by tea4two
HTML
<h1>simple AJAX call test</h1>
JavaScript
//1.create the request
var myRequest;
//feature check
if (window.XMLHttpRequest) {
myRequest = new XMLHttpRequest();//firefox, safari
} else if (window.ActiveXObject) {
myRequest = new ActiveXObject('Microsoft.XMLHTTP'); //IE
}
//2. create an event handler
myRequest.onreadystatechange = function() {
console.log('we were called!');
console.log(myRequest.readyState);
}
//3.open and send it
myRequest.open('GET','https://www.dropbox.com/s/vu1rs7ob9ll6qri/simple.txt',true);
//any parameter to send along?
myRequest.send(null);//nuh, not this time.