我正在使用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