簡體   English   中英

Internet Explorer不會在Ajax響應上重定向

[英]Internet Explorer doesn't redirect on ajax response

我將ajax發布請求發送到服務器,並以302重定向響應。 除IE外,所有瀏覽器均遵循此重定向。 我在IE開發工具的“網絡”標簽中看到收到302響應。

同樣,jQuery .fail(function(jqXHR, textStatus) {...})回調在jqXHR返回以下數據: [object Object]{readyState: 0, status: 0, statusText: "error"}

這很奇怪,因為狀態不是302。

在IE 11上進行測試。

編輯響應頭:

Response    HTTP/1.1 302 Found
Date    Tue, 27 Oct 2015 12:24:47 GMT
Server  Apache/2.4.10 (Debian) PHP/5.6.7-1
X-Powered-By    PHP/5.6.7-1
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
X-Redirect  http://mysiteaddress.com/somepage/
Set-Cookie  PHPSESSID=123; path=/; HttpOnly
Content-Length  0
Keep-Alive  timeout=15, max=96
Connection  Keep-Alive
Content-Type    text/html; charset=UTF-8

EDIT2我想這是Yii2框架特定的錯誤。 客戶端腳本必須處理X-REDIRECT標頭,但不能在IE中執行此操作。 請參閱: http : //www.yiiframework.com/doc-2.0/yii-web-response.html#redirect()-detail

當您使用yii \\ web \\ Response :: redirect()方法時,這是特定於Yii2的錯誤/行為。 如果您返回代碼200而不是正確的重定向代碼302,那么一切似乎都可以正常工作。

請參閱: http : //www.yiiframework.com/doc-2.0/yii-web-response.html#redirect () -detailhttps://github.com/yiisoft/yii2/issues/9670

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM