Ajax POSt在IE11中不起作用

Vim*_*aik 5 ajax redirect internet-explorer-11 yii2

我的网页上有一个按钮,它调用如下的ajax方法

    $.ajax({
        cache: false,
        type:'POST',
        data: 'type='+userType +'&user='+user ,
        url:' ".\yii\helpers\Url::to([$program.'/'.$url.'/setcustomer/'])."     ', 
        success: function(data) {
            console.log('Hii');
            $('#phoneErr').html(data);                            
        }
    });
Run Code Online (Sandbox Code Playgroud)

这适用于除IE11以外的所有浏览器,当我单击按钮时出现以下错误:

SCRIPT7002: XMLHttpRequest: Network Error 0x800c0008, The download of the    specified resource has failed.
Run Code Online (Sandbox Code Playgroud)

有人遇到过这个问题吗,对此有什么解决方案?

setcustomer操作中我的PHP代码中有重定向。这个问题可以和它有关吗?

我的ajax响应主体说,键值响应HTTP / 1.1 302找到并没有真正重定向到所需页面是与IE ajax相关的问题,无法成功处理ajax响应中的302重定向。

小智 0

我提出下一个解决方案:

在js中:

$(document).ajaxComplete(function (event, xhr, settings) {
    var url = xhr && xhr.getResponseHeader('X-Redirect');
    if (url) {
        window.location = url;
    }
});
Run Code Online (Sandbox Code Playgroud)

在 php (yii2) 中(即不通过 ajax 理解 302,我们发送 200):

$this->redirect(['index', 'id' => $model->id], 200);
Run Code Online (Sandbox Code Playgroud)