答对者全分奉送!!!如何将服务器端的图形文件流(Response.ContentType = "image/jpeg")回传到客户端的Image
用ajax技术作了一个图形的实时刷新;
服务器端动态生成图形(Pgh.aspx) :
...
Bitmap bmp = new Bitmap(stream);
Response.ContentType = "image/jpeg";
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
客户端Js如下:
function doStart()
{
createXMLHttpRequest();
var url = "Pgh.aspx";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = startCallback;
xmlHttp.send(null);
}
function startCallback()
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
var imgPgh = document.getElementById("ImgPgh");
///////////////////////////////////////////////////
//此处如何从xmhHttp的回传数据中得到图形数据呢????
///////////////////////////////////////////////////
imgPgh.src = xmlHttp.???????????????????
}
}
}
服务器端成功的生成了图形数据流,那么我怎么在客户端显示这个图形数据流呢????这个数据流在xmlHttp的reponse中,我怎么和我的客户端的Image.src相关联呢?