无法加载 chrome 中 500 内部服务器错误的响应

Sri*_*ddy 5 javascript ajax jquery google-chrome

我有从 UI 到后端的调用。后端将抛出 500 内部服务器错误和一些验证(如果有),我必须在前端显示它们。这是 Firefox 中的示例图像。火狐浏览器

但在 chrome 中,对于同一个调用,我无法收到任何响应。我不认为这是后端问题,因为调用在 Firefox 中工作。我的问题是,我的通话有问题吗?我是否缺少一些必须专门添加到 Chrome 中的 ajax 调用中的内容?这是来自 chrome 的图像。Chrome 问题

这是电话。

        $.ajax({
                type: 'GET',
                url: requestUrl,
                data:data,
                async : ajaxHeaders.async,
                success: function(response) {
                    options && options.success && options.success(response);
                },
                error: function(response) {
                    options && options.error && options.error(response);
                }
            });
Run Code Online (Sandbox Code Playgroud)

Sri*_*ddy 1

我已经发现问题了。chrome 有问题。如果分块响应未正确结束,则 chrome 无法读取它。但是,firefox 和 safari 正在内部处理这个问题。

因此,解决方案将在后端正确发送分块响应。Spring MVC有这个bug。我们可以做的是通过附加我们想要的响应正文来手动发送响应。