微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php-如何解决“拒绝设置不安全标题:连接”?

我正在结合使用Prototype和CodeIgniter来提交AJAX请求.我的浏览器是Chrome.我在控制台中收到一个错误,提示“拒绝设置不安全标题:连接”.这是Ajax请求行:

new Ajax.Request('/vbs/index.PHP/signup/get_ratecenters',{method:'POST', evalScripts:true})

我试图将类型设置为同步,但收到相同的错误.

有人可以协助吗?提前致谢.

解决方法:

prototype.js (1.7.0.0)中只有一个代码片段尝试设置连接: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';
  }
}

看看是否真的是原因.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐