对于XMLHttpRequest来说,这非常简单:
var xhr = new XMLHttpRequest();
xhr.open('POST', MyUrl, true);
xhr.setRequestHeader('Content-Type', 'application/json')但是我如何在XDomainRequest中实现这一点呢?
发布于 2013-10-25 01:38:49
不能覆盖XMLHttpRequest内容类型。您应该在服务器上正确设置它,例如,对于php:
header('Content-type: application/json');如果这是不可能的,那么您可以创建一个本地代理脚本,该脚本使用正确的标头来镜像您的跨域脚本
https://stackoverflow.com/questions/15113355
复制相似问题