var txtimg = new Image(); //img holder
$(txtimg).load(function() {
$("#div").append(this);
}).error(function() {
// notify the user that the image could not be loaded
alert('error loading text');
}).attr('src', webroot + '?drawtxt='+text.content);
上述代碼使用jQuery加載加載圖像。它適用於text.content爲普通字符的情況。但是,當text.content包含URL中不允許的特殊字符(如'&'字符,甚至編碼爲'%26')時,將無法加載圖像。如何用jQuery ajax返回圖片?
因此,我正在尋找一種方法來發送一些數據使用ajax,允許使用特殊字符,同時也能夠返回圖像。
如果我使用$ .ajax(),返回值是否包含二進制圖像流?如果不是,可以用特殊字符調用ajax並同時返回圖像的其他方法是什麼?
爲什麼不把圖像存儲在亞馬遜或其他東西(而不是數據庫)然後存儲網址?是不是更容易? – corroded 2011-03-30 05:21:36