Skip to content

Instantly share code, notes, and snippets.

@noqisofon
Created January 21, 2011 00:07
Show Gist options
  • Save noqisofon/788988 to your computer and use it in GitHub Desktop.
Save noqisofon/788988 to your computer and use it in GitHub Desktop.
XMLHttpRequest を使うサンプルを書きなおしてみた感じ
function getXMLHttpRequest() {
if ( _root.defined( `XMLHttpRequest ) )
return new XMLHttpRequest();
else {
try {
return ActiveXObjectFactory.createObject( "MSXML2.XMLHTTP.3.0" );
} catch ( e : Exception ) {
return null;
}
}
}
function onReadyStateChange(ae : AsyncEvent) {
if ( ae.sender.readyState == ReadyState.DONE ) {
if ( ae.sender.status == 200 )
alert( ae.sender.responseText );
}
}
let request = getXMLHttpRequest();
if ( request != null ) {
request.open( "GET", "http://localhost/sample.xml", true );
request.addEventListener( AsyncEvent.READY_STATE_CHANGE, onReadyStateChange, false );
request.send();
} else
alert( "XMLHttpRequest not supported." );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment