PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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';
  }
}

看看是否真的是原因.

大佬总结

以上是大佬教程为你收集整理的php-如何解决“拒绝设置不安全标题:连接”?全部内容,希望文章能够帮你解决php-如何解决“拒绝设置不安全标题:连接”?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: