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

ufku’s picture

Status: Needs work » Closed (works as designed)

Iframe upload requires text/html response.

zcx.wang’s picture

Actually, 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.

ben_chad’s picture

This 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

ufku’s picture

Recently committed some changes that eliminate the need for iframe and text/html header for modern browsers.