从jquery迁移到执行CORS调用的原型脚本时遇到了一些问题。
与jquery一样,它适用于所有浏览器。但出于某种原因,它不愿意在原型
下使用IEIIS HTTP RESPONSE标头
Access-Control-Allow-Headers : X-PINGOTHER, Content-Type, X-Requested-By, X-Requested-With, Accept, Origin, Accept-Language, User-Agent, Cache-Control, Pragma, Date, X-Prototype-Version, X-JSON, Accept-Encoding, DNT, HOST, Cache-Control
Access-Control-Allow-Methods : POST, GET, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin : *
Access-Control-Max-Age : 1728000;
Javascript来电来源
new Ajax.Request(api.settings.host, {
asynchronous: false,
method: 'post',
contentType:'application/xml',
encoding:'UTF-8',
postBody: api.getData(),
onSuccess: function(result) {}});
已发送标头(chrome)
Request URL:*/soap/
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:text/javascript, text/html, application/xml, text/xml, */*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:8403
Content-type:application/xml; charset=UTF-8
DNT:1
Host:*
Origin:*
Referer:*
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
X-Prototype-Version:1.7
X-Requested-With:XMLHttpRequest
IE控制台错误:访问被拒绝。
抛出错误的原型代码行:
this.transport.open(this.method.toUpperCase(), this.url,this.options.asynchronous);
我还尝试过添加自定义标头处理
Ajax.Responders.register({
onCreate: function(response) {
if (response.request.isSameOrigin())
return;
var t = response.transport;
t.setRequestHeader = t.setRequestHeader.wrap(function(original, k, v) {
if (/^(accept|accept-language|content-language)$/i.test(k))
return original(k, v);
if (/^content-type$/i.test(k) &&
/^(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain|application\/xml)(;.+)?$/i.test(v))
return original(k, v);
return;
});
}
});
从我看到的电话甚至没有发出。
同样准确地说,协议从http更改为https
有什么建议吗?