Created
January 21, 2011 00:07
-
-
Save noqisofon/788988 to your computer and use it in GitHub Desktop.
XMLHttpRequest を使うサンプルを書きなおしてみた感じ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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