Search code examples
jqueryjquery-file-uploadjquery-iframe-transport

How to parse the result from jquery upload file plugin with jquery.iframe-transport plugin?


I use jQuery File Upload Plugin 5.26 https://github.com/blueimp/jQuery-File-Upload

Because I need to append extra parameters for my file.ashx to process request, I added jquery.iframe-transport.js as suggested in jQuery File Uploader IE9 Not posting any params on Upload

My file.ashx still returns me json string (text/plain) result as shown in fiddler, but in the done callback I only got some weird data structure which contains the forms, files and html element kind of like a iframe or stuff. How can I get my json string (text/plain) result?

Thanks.


Solution

  • As described in https://github.com/blueimp/jQuery-File-Upload/issues/659#issuecomment-2999298

    the result is wrapped into HTML.

    So the callback just needs one more step to extract the result from HTML like below

    function(e, data) {
        var result = $.parseJSON($('pre', data.result).text());
        // and result can be used like before
    }