<script type="text/javascript">
function testXmlHttpRequestObj(xmlURL){
/* XMLHttpRequestオブジェクト作成 */
var xmlhttp=false;
if(typeof ActiveXObject!="undefined"){ /* IE5, IE6 */
try {
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); /* MSXML3 */
}
catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); /* MSXML2 */
}
}
if(!xmlhttp && typeof XMLHttpRequest!="undefined"){
xmlhttp=new XMLHttpRequest(); /* Firefox, Safari, IE7 */
}
if(!xmlhttp){
alert("XMLHttpRequest非対応ブラウザ");
return false;
}
/* レスポンスデータ処理 */
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
/* XMLデータ取得 */
document.getElementById("resXmlHttpRequestObj").innerHTML=xmlhttp.responseXML;
}
}
/* HTTPリクエスト初期化+HTTPメソッドおよびリクエスト先URLの設定 */
xmlhttp.open("GET",xmlURL,true);
/* ★サーバーにリクエスト送信 */
xmlhttp.send("");
}
window.onload=function(){
/* ページ読み込み完了時に実行 */
testXmlHttpRequestObj("./xml/ranking.xml");
}
</script>
<div id="resXmlHttpRequestObj"></div>