首页 > 技术文章 > Refused to set unsafe header "Connection"

tinyking 原文

参考 http://stackoverflow.com/questions/7210507/ajax-post-error-refused-to-set-unsafe-header-connection

使用ajax时,chrome报出异常:Refused to set unsafe header "Connection"。

xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

在XMLHttpRequest不允许设置一些headers,他们会被浏览器自动设置。

推荐阅读