Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the inc/imce.page.inc file, the function imce_js set different content-type to the JSON response. However, I think operations including upload all return a JSON response, so that the Content-Type should be consistent. In addition, setting a JSON response to a text/html type is not correct.
The problem is in the js/imce.js file. In the uploadSettings, you missed the 'type' and 'dataType' properties and you don't need to use $.parseJSON to parse the response, just as what you have done with other operations.
Comments
Comment #1
ufku CreditAttribution: ufku commentedIframe upload requires text/html response.
Comment #2
zcx.wang CreditAttribution: zcx.wang commentedActually, I do not think this is a good design. I have modified it and it seems works fine. I hope you can consider this issue in the future release.
Comment #3
ben_chad CreditAttribution: ben_chad commentedThis is a bit unfortunate for everyone. The ``incorrect" json header causes an incompatibility with the memcache module, for example. See https://drupal.org/node/2091107
According to RFC 4627, the correct content type should be ``application/json". See http://www.ietf.org/rfc/rfc4627.txt
See blueimp's suggestion about using the Accept header as a partial workaround for this at https://github.com/blueimp/jQuery-File-Upload/issues/1795. I would consider using this approach if possible, and in the correct case, use drupal_json_encode to correctly set the header and output the JSON response.
B
Comment #4
ufku CreditAttribution: ufku commentedRecently committed some changes that eliminate the need for iframe and text/html header for modern browsers.