What should the value of content-type http header be if the message body is JSONP. application/javascript?
Asked
Active
Viewed 1.3k times
2 Answers
15
Depends on the body's actual content. That's what the Content-Type
header stands for.
So, if you write a JS callback function to the body, then yes, it should be application/javascript
.
Or, if you write a JSON string to the body, then no, it should be application/json
instead.

BalusC
- 1,082,665
- 372
- 3,610
- 3,555
0
If you want ajax to work for the case in which you have a file upload field in a form as part of the input, and you aren't using XHR2, it must be 'text' or 'text/html' and you need to surround it with a fake HTML element. See the jquery forms ajax support doc for all the nasty details.

bmargulies
- 97,814
- 39
- 186
- 310
-
_"you need to surround it with a fake HTML element"_ - That isn't true, I've done Ajax in FF with JSON (no html). – nnnnnn Aug 23 '12 at 12:32