weixin_33691817 2015-10-06 07:36 采纳率: 0%
浏览 450

Ajax POSt在IE11中不起作用

I have a button in my webpage which calls an ajax method a s below

    $.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);                            
        }
    });

This works in all browsers except IE11 I get the following error when i click on the button:

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

Has anyone faced this issue and what is the solution to this?

There is a redirection in my PHP code in the setcustomer action. Can this issue be related to it?

My ajax response body says Key Value Response HTTP/1.1 302 Found and not actually redirecting to the required page is the problem related to IE ajax cannot handle 302 redirect within an ajax response as success.

  • 写回答

1条回答 默认 最新

  • YaoRaoLov 2017-08-17 22:45
    关注

    I make the next solution:

    in js:

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

    in php (yii2) (ie not understand 302 via ajax, we send 200) :

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

报告相同问题?