I ran across an interesting bug with the JQuery thickbox, I pointed it to a URL which was an ASP.NET ashx handler that generates thumbnail images, the result in the browser was this garbled response:
Using Firebug we see that it expects the result to be text/html
Looking at the code it is obvious what the problem is:
1: var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
2: var urlType = baseURL.toLowerCase().match(urlString);
3:
4: if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp') {//code to show images
The code looks at the extension of what it is calling, if it finds any of the common image types, it will send a different request type, so adding the .ashx extension will fix the issue:
1: var urlString = /\.jpg$|\.jpeg$|\.png$|\.ashx$|\.gif$|\.bmp$/;
2: var urlType = baseURL.toLowerCase().match(urlString);
3:
4: if (urlType == '.jpg' || urlType == '.jpeg' || urlType == '.ashx' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp') {//code to show images
I’ve just simply added the .ashx as a file extension that should be treated as an image type, this fixed the issue.