【发布时间】:2023-03-31 18:20:01
【问题描述】:
我有从 UI 到后端的调用。后端将抛出 500 个内部服务器错误和一些验证(如果有),我必须在前端显示它们。这是它在 Firefox 中的示例图像。Firefox
但是在同一呼叫的 chrome 中,我无法收到任何响应。我不认为这是一个后端问题,因为调用在 Firefox 中工作。我的问题是,我的电话有问题吗?我是否遗漏了必须专门添加到 chrome 中的 ajax 调用的内容?这是来自 chrome 的图片。Chrome issue
来电了。
$.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);
}
});
【问题讨论】:
-
你手动抛出 500 错误吗?
-
是的。在后端手动抛出异常(Spring MVC)
-
为什么不直接返回带有错误键的 JSON?
-
服务器正在返回 JSON,我可以看到它并在 Firefox 中使用它。该问题仅出现在 Chrome
-
也许 Chrome 得到错误响应(标题)并忽略任何输出?
标签: javascript jquery ajax google-chrome