What problems may using the MIME type application/json cause?

后端 未结 3 1983
不知归路
不知归路 2020-12-21 06:10

I am working on a web service the needs to return JSON data. I read that I should use application/json but am not sure what problems this may cause?

For example, w

3条回答
  •  独厮守ぢ
    2020-12-21 06:41

    Having just had a long fight with IE8 myself with this I found that if you're loading the json into an iframe as text/plain, IE8 will wrap this in a tag. If you then fetch the content out with innerHTML and try to parse this as json, it'll fail.

    I ended up having to send the content as text/html, which just seems totally wrong, but works in IE and doesn't seem to mess up other browsers more modern AJAX handling.

提交回复
热议问题