2011-06-08 120 views
0

我想在我的頁面中顯示圖像,但是我面對的問題是我的網頁顯示所有.jpeg圖像,但它不顯示* .png圖像爲什麼是?在網頁上顯示.png圖片

$.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+q+"&json.wrf=?", function(result){ 
    var html=""; 
    // If no search results 
    if(result.response.numFound==0) 
    { 
    html+= "<br>We're sorry, we found no results for <b>"+document.getElementById("queryString").value; 
    } 
    else 
    { 
     html+= "<br>Total Results Found <b> "+ result.response.numFound+"</b> for "+"<b>"+document.getElementById("queryString").value+"</b> keyword"; 
     // Parse solr response and display it on web page 
      $.each(result.response.docs, function(i,item){ 
      var src1=item.image; 
      // Check if there is a image 
       if(src1!= null && src1!= ""){ 

         html+="<p><br>"+"<img src="+src1+ " />"; 
        } 
      // If not insert a default image 
        else 
        { 

         src1="images/products/default.bmp"; 
         html+="<p><br>"+"<img src="+src1+ " />"; 
        } 
        html += "<br>UID_PK: ="+ item.UID_PK; 
        html += "<br>Name: ="+ item.name; 
       // html += "<br>Description: ="+ item.description; 
       html+="<br>Price:="+item.price 
      }); 
    } 

      $("#result").html(html); 
+0

你使用什麼瀏覽器和版本? – Shad 2011-06-08 06:14:38

+0

Mozilla Firefox 3.6 – Romi 2011-06-08 06:41:46

+0

Firebug對這些圖片請求中的每一個都說了些什麼?如何通過在瀏覽器地址欄中輸入他們的直接地址來單獨查看這些圖像? – BalusC 2011-06-08 11:52:49

回答

1
<img src="/path/to/my/image.png" alt="My Image" /> 
+0

我能夠以這種方式顯示.jpeg圖像,問題是它不顯示.png圖像 – Romi 2011-06-08 06:13:20

+0

@Romi它不能這樣你可能會錯誤的路徑 – 2011-06-08 07:26:53

+0

我得到json對象並解析它獲取圖像路徑,此路徑包含jpeg和png類型的圖像,但我可以顯示.jpeg但不顯示.png。我已檢查過我的圖像文件夾包含兩種類型的圖像 – Romi 2011-06-08 07:37:19

2

首先嚐試手動加載使用瀏覽器的地址欄中的圖像。如果有效,那麼<img>標籤或文件路徑存在問題。使用Firebug或類似的瀏覽器插件來追蹤它。

如果這不起作用,並且該文件肯定存在,那麼它可能是一個帶有服務器或文件權限的MIME類型問題。檢查您的服務器的錯誤日誌以獲取更多信息。

希望幫助您的PNG

0

檢查文件的訪問權限。

+0

請嘗試閱讀這個http://stackoverflow.com/about,以獲得更多關於SO的問題和解答。你的貢獻沒有回答這個問題。這更多的是一個評論,你可以添加一次,你會增加你的聲譽:http://stackoverflow.com/faq#reputation – 2013-09-22 09:48:49