2

AJAX リクエストでリンクのコンテンツ (バイナリ イメージであるhttp://pastebin.ca/raw/2314500など)を取得したいと考えています。Javascriptでバイナリ文字列を読み取る方法は? 次のコードは機能しません。

function httpGet(theUrl)
{
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            return xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET", theUrl, false );
    xmlhttp.send();    
}

alert(httpGet("http://pastebin.ca/raw/2314500"))
4

0 に答える 0