[英]JSONP response http content-type header
What should the value of content-type http header be if the message body is JSONP.如果消息体是 JSONP,content-type http header 的值应该是多少? application/javascript?
应用程序/javascript?
Depends on the body's actual content.取决于身体的实际内容。 That's what the
Content-Type
header stands for.这就是
Content-Type
header 的含义。
So, if you write a JS callback function to the body, then yes, it should be application/javascript
.所以,如果你写一个 JS 回调 function 到正文,那么是的,它应该是
application/javascript
。
Or, if you write a JSON string to the body, then no, it should be application/json
instead.或者,如果您将 JSON 字符串写入正文,那么不,它应该是
application/json
。
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.如果您希望 ajax 在表单中有一个文件上传字段作为输入的一部分并且您没有使用 XHR2 的情况下工作,它必须是“文本”或“文本/html”,您需要用一个假的 HTML 元素包围它。 See the jquery forms ajax support doc for all the nasty details.
有关所有讨厌的细节,请参阅 jquery forms ajax 支持文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.