我正在使用Prototype与CodeIgniter结合来提交AJAX请求。我的浏览器是Chrome。我在控制台收到错误消息“拒绝设置不安全标题:连接”。下面是Ajax请求行:如何解决“拒绝设置不安全标题:连接”?
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
我已经尝试的类型设置为同步的,但收到了同样的错误。
有人可以协助吗?提前致谢。
我正在使用Prototype与CodeIgniter结合来提交AJAX请求。我的浏览器是Chrome。我在控制台收到错误消息“拒绝设置不安全标题:连接”。下面是Ajax请求行:如何解决“拒绝设置不安全标题:连接”?
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
我已经尝试的类型设置为同步的,但收到了同样的错误。
有人可以协助吗?提前致谢。
如果您直接在浏览器中加载/vbs/index.php/signup/get_ratecenters
,会发生什么情况?
我read somewhere online“拒绝设置不安全标题:连接”是一个警告,HTTP“连接”标题无法设置,但并不意味着请求将不会被处理,所以可能还有其他事情正在进行这里?
检查/vbs/index.php/signup/get_ratecenters
并确保它返回有效的JavaScript代码。在Chrome控制台中执行该代码,并确保它没有错误...可能这里有一个不同的错误。
有一个在prototype.js (1.7.0.0)试图设置Connection: 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';
}
如果您使用的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';
}
}
只有一个代码片段
,看看它是否真的是原因。
是的,这是真正的原因。 –
Josh,你有关于如何面对这个问题的任何更新,我的第一个与“连接”和“保持活着”头的请求处理与警告,如你所说--->“拒绝设置不安全的头'连接'。”我后来的请求失败。你能否对此表达一些看法...谢谢 – BetRob