当Angulars $ http.post与大型/复杂json数据集一起使用时,Internet Explorer 11崩溃

Gre*_*reg 5 internet-explorer json angularjs internet-explorer-11

当我使用Angulars $ http.post方法发布大型/复杂的json对象时,我始终能够崩溃IE11.

我已经设置了一个角度示例,可以在IE11中运行以查看我遇到的行为:http://plnkr.co/edit/yYaDy8d00VGV6WcjaUu3?p = preview

这是导致崩溃的代码:

$http.post($scope.saveDocumentUrl, { "document": doc, "submit": submit, "trash": trash }).success(function (data) {
            if (!data.Success) {
                bootbox.alert(data.Message);
            } else {
                if (trash) {
                    $scope.periodReviewDocuments.pop(doc);
                    hideModalWindow(); //we call this in the event that the method was called from the document and not from the list.
                }

                if(submit){
                    $scope.periodReviewDocuments.pop(doc);
                    resetForm();
                    bootbox.alert("Your document has been submitted");
                    hideModalWindow();                        
                }

            }
            $scope.isBusy = false;
        }).error(function (data, status) {
            $scope.isBusy = false;
            bootbox.alert("The server encountered an error and could not save your document. If this problem persists please contact the administrators");
        });
Run Code Online (Sandbox Code Playgroud)

这是jquery工作代码:

    $.ajax({
            url: $scope.saveDocumentUrl,
            data: JSON.stringify({ "document": doc, "submit": submit, "trash": trash }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            type: "POST"
        }).done(function (data) {
            if (!data.Success) {
                bootbox.alert(data.Message);
            } else {
                if (trash) {
                    $scope.periodReviewDocuments.pop(doc);
                    hideModalWindow(); //we call this in the event that the method was called from the document and not from the list.
                }

                if (submit) {
                    $scope.periodReviewDocuments.pop(doc);
                    resetForm();
                    bootbox.alert("Your document has been submitted");
                    hideModalWindow();
                }

            }
            $scope.isBusy = false;
        }).fail(function (data, status) {
                $scope.isBusy = false;
                bootbox.alert("The server encountered an error and could not save your document. If this problem persists please contact the administrators");
        })
Run Code Online (Sandbox Code Playgroud)

这是我目前所知道的:

  1. 此问题仅发生在IE11 - Windows 8.1/IE 11(11.0.9600.17498)中.更新版本11.0.15(KB3008923).
  2. 发送请求后浏览器崩溃.
  3. 我检查了服务器端的传入请求,并且有效负载已经完美地序列化/反序列化.
  4. 我用jquery $ .ajax替换了$ http.post函数,它解决了这个问题,但这不是解决方案,因为我使用的是angular.
  5. 我在这个问题上已经失去了3天

Gre*_*ner 3

在您的 Internet Explorer 版本中,使用翻译过滤器调用 JSON.stringify 会使 IE 在处理大型数据集时崩溃。

这里的技巧是在传递给 $http.post 之前自己对对象进行字符串化

http://plnkr.co/edit/PbMxMY?p=preview

  var body = {"document" .....

  var jsonData = JSON.stringify(body);

  $http.post("/test", jsonData).then(function(response) {
    console.log(response.data);
  });

  $interval(function() {
    $rootScope.tick = Date.now();
  }, 500);
});
Run Code Online (Sandbox Code Playgroud)