【问题标题】:Ajax POSt not working in IE11Ajax POST 在 IE11 中不起作用
【发布时间】:2016-01-03 00:49:24
【问题描述】:

我的网页中有一个按钮,它调用下面的 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);                            
        }
    });

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

SCRIPT7002: XMLHttpRequest: Network Error 0x800c0008, The download of the    specified resource has failed.

有人遇到过这个问题吗?解决办法是什么?

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

我的 ajax 响应正文显示键值 响应 HTTP/1.1 302 找到 而实际上并没有重定向到所需的页面 是与 IE ajax 相关的问题无法将 ajax 响应中的 302 重定向处理为成功。

【问题讨论】:

  • 如果是由于 url 前面的链接中所述,它不应​​该在其他浏览器中工作吗?还是 IE11 有什么不同?

标签: ajax redirect yii2 internet-explorer-11


【解决方案1】:

我提出下一个解决方案:

在js中:

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

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

$this->redirect(['index', 'id' => $model->id], 200);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-06
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    • 1970-01-01
    • 2012-06-07
    • 2015-11-19
    • 1970-01-01
    相关资源
    最近更新 更多