0

我尝试使用 .NET 和 MSIE 8 获取所需内容的每一种方式都失败了:由于我无法使用“GET”预加载图像,我决定将它们放入 base64:它们可以到达客户端,但是在那里我发现 MSIE8 无法管理超过 32Kb 的 base64,所以我又失望了。所以我又回到了我在网上找到了几次的经典方法,结果如下:

var img = new Image();
var ajax = new ActiveXObject('Microsoft.XMLHTTP');
ajax.open("GET", url, false)
ajax.send(null);
var res = ajax.status;
if (res == 200)    // succès
{
    // this program crashes on next line as soon as 'url' points a jpg file
    var tx = rajax.responseText;
    // this program crashes on previous line except if 'url' points a text file
    img.src = tx;
}

那么我该怎么做才能以这种方式加载我的图像?谢谢你的帮助。

4

1 回答 1

0

你对src物业有误解。

src接受一个 URL,而不是一个实际的图像。
您不需要任何 AJAX。

于 2012-04-17T00:38:43.177 回答