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);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!