admin管理员组文章数量:1024424
I'm using Prototype bined with CodeIgniter to submit an AJAX request. My browser is Chrome. I'm receiving an error in the console that reads "Refused to set Unsafe Header: Connection". Here is the Ajax Request line:
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
I've attempted to set the type to synchronous, but received the same error.
Can someone assist? Thanks in advance.
I'm using Prototype bined with CodeIgniter to submit an AJAX request. My browser is Chrome. I'm receiving an error in the console that reads "Refused to set Unsafe Header: Connection". Here is the Ajax Request line:
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
I've attempted to set the type to synchronous, but received the same error.
Can someone assist? Thanks in advance.
Share Improve this question edited Dec 27, 2011 at 16:47 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Aug 25, 2011 at 14:05 Derek BrownDerek Brown 531 silver badge4 bronze badges2 Answers
Reset to default 4There's only one code fragment in prototype.js (1.7.0.0) that attempts to set a Connection: close
header
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 you're using a local copy of prototype.js you could change the code fragment to
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';
}
}
and see if it's really the cause.
What happens if you load /vbs/index.php/signup/get_ratecenters
directly in your browser?
I read somewhere online that "Refused to set Unsafe Header: Connection" is a warning that the HTTP "Connection" header cannot be set, but doesn't mean the request will not be processed, so it's possible something else is going on here?
Check /vbs/index.php/signup/get_ratecenters
and make sure it returns valid JavaScript code. Execute that code in the Chrome console and make sure it is error free... possibly here's a different error here.
I'm using Prototype bined with CodeIgniter to submit an AJAX request. My browser is Chrome. I'm receiving an error in the console that reads "Refused to set Unsafe Header: Connection". Here is the Ajax Request line:
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
I've attempted to set the type to synchronous, but received the same error.
Can someone assist? Thanks in advance.
I'm using Prototype bined with CodeIgniter to submit an AJAX request. My browser is Chrome. I'm receiving an error in the console that reads "Refused to set Unsafe Header: Connection". Here is the Ajax Request line:
new Ajax.Request('/vbs/index.php/signup/get_ratecenters',{method:'POST', evalScripts:true})
I've attempted to set the type to synchronous, but received the same error.
Can someone assist? Thanks in advance.
Share Improve this question edited Dec 27, 2011 at 16:47 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Aug 25, 2011 at 14:05 Derek BrownDerek Brown 531 silver badge4 bronze badges2 Answers
Reset to default 4There's only one code fragment in prototype.js (1.7.0.0) that attempts to set a Connection: close
header
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 you're using a local copy of prototype.js you could change the code fragment to
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';
}
}
and see if it's really the cause.
What happens if you load /vbs/index.php/signup/get_ratecenters
directly in your browser?
I read somewhere online that "Refused to set Unsafe Header: Connection" is a warning that the HTTP "Connection" header cannot be set, but doesn't mean the request will not be processed, so it's possible something else is going on here?
Check /vbs/index.php/signup/get_ratecenters
and make sure it returns valid JavaScript code. Execute that code in the Chrome console and make sure it is error free... possibly here's a different error here.
本文标签: phpHow to Address quotRefused to Set Unsafe Header ConnectionquotStack Overflow
版权声明:本文标题:php - How to Address "Refused to Set Unsafe Header: Connection"? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745500605a2153373.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论