Ajax Complete函数没有在firefox和IE中执行

时间:2016-08-17 05:26:42

标签: javascript jquery ajax

我有一个ajax函数,我正在尝试下载文件,然后重定向到下一页。它在chrome中完美运行,但在firefox和IE中却没有。 这是我的JS代码

function GenerateMsi() {
            var obj = {};
            obj.establishmentGuid = '@Model.InformEstablishmentGuid';
            obj.networkType = $('input[name=sit]:checked').val();
            $.ajax({
                type: "POST",
                url: "@Url.Action("GenerateMsi", "Establishment")",
                data: obj,
                success: function (data) {
                    var uri = data.msiLocation;
                    uri = uri.replace(/\s+/g, '%20');
                    this.link = document.createElement("a");
                    this.link.href = uri;

                    //set the visibility hidden so it will not effect on your web-layout
                    this.link.hidden = true;
                    this.link.download = data.filename;

                    //this part will append the anchor tag and remove it after automatic click
                    document.body.appendChild(this.link);
                    this.link.click();
                    document.body.removeChild(this.link);
                },
                complete: function (data) {
                    window.location.href= data.redirectUrl;
                },
                error: function () {
                    alert("Some error occured in the server!")
                }
            });
        }

注意:如果没有该下载功能,则会重定向到下一页。 请帮我解决问题

0 个答案:

没有答案