pen*_*ake 5 javascript http xmlhttprequest cors xdomainrequest
对于XMLHttpRequest,它非常简单:
var xhr = new XMLHttpRequest();
xhr.open('POST', MyUrl, true);
xhr.setRequestHeader('Content-Type', 'application/json')
但是我如何为XDomainRequest实现这一目标?
无法覆盖 XMLHttpRequest 内容类型。您应该在服务器上正确设置它,例如对于 php:
header('Content-type: application/json');
如果这是不可能的,那么您可以创建一个本地代理脚本,该脚本使用正确的标头镜像您的跨域脚本
| 归档时间: | 
 | 
| 查看次数: | 4287 次 | 
| 最近记录: |