Php 如何解决;拒绝设置不安全的标头:连接“;?
我使用Prototype结合CodeIgniter来提交AJAX请求。我的浏览器是Chrome。我在控制台中收到一个错误,内容为“拒绝设置不安全的头:连接”。以下是Ajax请求行:Php 如何解决;拒绝设置不安全的标头:连接“;?,php,javascript,ajax,codeigniter,prototypejs,Php,Javascript,Ajax,Codeigniter,Prototypejs,我使用Prototype结合CodeIgniter来提交AJAX请求。我的浏览器是Chrome。我在控制台中收到一个错误,内容为“拒绝设置不安全的头:连接”。以下是Ajax请求行: new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true}) 我试图将类型设置为synchronous,但收到了相同的错误 有人能帮忙吗?提前感谢。如果直接在浏览器中加载/vbs/index.p
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
我试图将类型设置为synchronous,但收到了相同的错误
有人能帮忙吗?提前感谢。如果直接在浏览器中加载
/vbs/index.php/signup/get_ratecenters
会发生什么
我认为“拒绝设置不安全的头:连接”是一个警告,说明无法设置HTTP“连接”头,但这并不意味着请求将不会被处理,因此可能还有其他问题
检查
/vbs/index.php/signup/get_ratecenters
,确保它返回有效的JavaScript代码。在Chrome控制台中执行该代码并确保其无错误。。。这里可能有另一个错误。中只有一个代码片段试图设置连接:close
头
if (this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');
/* Force "Connection: close" for older Mozilla browsers to work
* around a bug where XMLHttpRequest sends an incorrect
* Content-length header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType &&
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
headers['Connection'] = 'close';
}
if(this.method==“post”){
标题['Content-type']=this.options.contentType+
(this.options.encoding?';字符集='+this.options.encoding:“”);
/*强制“连接:关闭”让旧版Mozilla浏览器工作
*围绕XMLHttpRequest发送错误消息的错误
*内容长度标题。参见Mozilla Bugzilla#246651。
*/
如果(this.transport.overrideMetype&&
(navigator.userAgent.match(/Gecko\/(\d{4})/)| |[02005])[1]<2005)
标题['Connection']='close';
}
如果您使用的是prototype.js的本地副本,那么可以将代码片段更改为
if (this.method == 'post') {
headers['Content-type'] = this.options.contentType +
(this.options.encoding ? '; charset=' + this.options.encoding : '');
/* Force "Connection: close" for older Mozilla browsers to work
* around a bug where XMLHttpRequest sends an incorrect
* Content-length header. See Mozilla Bugzilla #246651.
*/
if (this.transport.overrideMimeType &&
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
{
alert("Yes, this is it.");
if ( navigator.userAgent.match(/Gecko\/(\d{4})/) ) {
alert("navigator");
}
headers['Connection'] = 'close';
}
}
if(this.method==“post”){
标题['Content-type']=this.options.contentType+
(this.options.encoding?';字符集='+this.options.encoding:“”);
/*强制“连接:关闭”让旧版Mozilla浏览器工作
*围绕XMLHttpRequest发送错误消息的错误
*内容长度标题。参见Mozilla Bugzilla#246651。
*/
如果(this.transport.overrideMetype&&
(navigator.userAgent.match(/Gecko\/(\d{4})/)| |[02005])[1]<2005)
{
警惕(“是的,就是它。”);
if(navigator.userAgent.match(/Gecko\/(\d{4})/){
警报(“导航器”);
}
标题['Connection']='close';
}
}
看看这是否是真正的原因。Josh,您是否有任何关于如何面对此问题的更新,我的第一个带有“连接”和“保持活动”标题的请求在处理时会发出警告,如您所述-->“拒绝设置不安全的标题‘连接’。”我随后的请求失败。你能不能帮我解释一下。。。非常感谢。