
// 通信関数
function createXMLHttpRequest(){
    var XMLhttpObject = null;
    try{
        XMLhttpObject = new XMLHttpRequest();
    }catch(e){
        try{
            XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
                return null;
            }
        }
    }
    return XMLhttpObject;
}

// 出力関数
function displayData(){
    if( ( httpObj.readyState == 4 ) && ( httpObj.status == 200 ) ) {
        document.getElementById( "result" ).innerHTML = httpObj.responseText;
        
    }
}

// ファイル読込関数
function loadTextFile( filename ) {
    httpObj = createXMLHttpRequest();
    httpObj.onload = displayData;
    httpObj.open( "GET", filename + "?cache=" + ( new Date() ) . getTime(), true );
    httpObj.send( null );
}

window.onload = function (){
    loadTextFile( 'data/news.txt' );
}