English 中文(简体)
利用AJAX并回归图像
原标题:Using AJAX and return a picture

I have a problem receiving and opening a picture via AJAX. If I call the following page:

http://127.0.0.1:8889/ex?sql=SELECT+Image+FROM+Persons+WHERE+Number+Like+%27%2501%27

a picture is displayed from a blob field in IE8.

Now I would like to open this into a div after someone pressed a key (using AJAX)?
Trying to use xhr.responseText does not work (I get an error. Using it on a text response works). So it seems that my problem is to grab the result from the ajax request.

我如何能够这样做?

一些法典和错误信息:

var picReturn = xhr.responseText;

=> 由于以下错误,可能无法继续:00ce514

问题回答

你有三种选择:

  1. Place the resultant data in an iframe. Not very practical.
  2. Take the result and place it in am image source as a data:uri. Not supported in older browsers and limited to 32/64Kb depending on the browser.
  3. Skip the AJAX and write a web service and use that as your url. This is the best option.

你不说你使用服务器的用词,但你基本上想打开网络的对策,把标题定在“image/jpeg”上,并返还你的流子。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签