Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display an ashx image using jQuery?

I've been trying to use the jQuery plugin Colorbox to display images I have in my DB through an ashx file. Unfortunately it just spits a bunch of gibberish at the top of the page and no image. Can this be done? Here is what I have so far:

   $(document).ready
   (
       function () 
       {
           $("a[rel='cbImg']").colorbox(); 
       }
   );
...
<a rel="cbImg" href="HuntImage.ashx?id=15">Click to see image</a>

UPDATE:

My ashx file is writing the binary out:

            context.Response.ContentType = "image/bmp";
            context.Response.BinaryWrite(ba);
like image 641
Abe Miessler Avatar asked Dec 30 '10 04:12

Abe Miessler


1 Answers

Colorbox has an option 'photo'. If you set this to true in your constructor then it will force it to render the photo.

$(target).colorbox({photo: true});
like image 57
James South Avatar answered Sep 18 '22 05:09

James South