Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 13th, 2012  |  syntax: None  |  size: 1.38 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Display .png image on a web page
  2. $.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+q+"&json.wrf=?", function(result){
  3.     var html="";
  4.     // If no search results
  5.     if(result.response.numFound==0)
  6.     {
  7.      html+= "<br>We're sorry, we found no results for <b>"+document.getElementById("queryString").value;
  8.     }
  9.     else
  10.     {
  11.       html+= "<br>Total Results Found <b> "+ result.response.numFound+"</b> for "+"<b>"+document.getElementById("queryString").value+"</b> keyword";
  12.         // Parse solr response and display it on web page
  13.             $.each(result.response.docs, function(i,item){
  14.              var src1=item.image;
  15.              // Check if there is a image  
  16.                 if(src1!= null && src1!= ""){
  17.  
  18.                       html+="<p><br>"+"<img src="+src1+ " />";
  19.                   }
  20.             // If not insert a default image  
  21.                   else
  22.                   {
  23.  
  24.                       src1="images/products/default.bmp";
  25.                       html+="<p><br>"+"<img src="+src1+ " />";
  26.                   }
  27.                   html += "<br>UID_PK: ="+ item.UID_PK;
  28.                   html += "<br>Name: ="+ item.name;
  29.                  // html += "<br>Description: ="+ item.description;
  30.                  html+="<br>Price:="+item.price
  31.             });
  32.     }
  33.  
  34.             $("#result").html(html);
  35.        
  36. <img src="/path/to/my/image.png" alt="My Image" />