jQuery FancyBox with Ajax

后端 未结 2 1687
梦毁少年i
梦毁少年i 2020-12-04 03:55

I have look at many web sites and many pages on Stackoverflow, but none of them has solved my problem yet. Simply, I have a hyperlink and I want to retrieve an

相关标签:
2条回答
  • 2020-12-04 04:21

    This should work. Looks like image is stored as JSON. If so, I think you should convert it back to Base64 before sending it to the browser. See http://mobile.cs.fsu.edu/converting-images-to-json-objects/

    function downloadFile(id) {
        $('#fancybox-inner').html('<img height="200" width="250" src="/Issue/RenderImage?ID='+id+'" />');
    }
    
    0 讨论(0)
  • 2020-12-04 04:35

    Better try

    success: function (response) {
        $.fancybox({
            content: '<img height="200" width="250" src="data:image/png;base64,' + response + '" />',
            type: "html"
        });
    }  
    

    I wonder why you trying to load the content inside a fancybox container when you don't show any code where you already opened it. Anyways, it's always better to launch a new fancybox with the new content (from ajax response)

    Of course, this will work if the ajax call is returning the correct response for your <img> tag, but that I cannot tell.

    0 讨论(0)
提交回复
热议问题