【问题标题】:Cross domain ajax does not work with redirect in mobile safari跨域 ajax 不适用于移动 Safari 中的重定向
【发布时间】:2012-07-27 07:10:45
【问题描述】:

我遇到了这个 WebKit 错误中提到的问题: https://bugs.webkit.org/show_bug.cgi?id=57600

问题在于移动 Safari,它适用于 Google Chrome 和 Firefox。我重定向跨域 ajax 请求的相同代码适用于 Google Chrome 和 Firefox,但不适用于移动 Safari。

据我了解,该错误是在 WebKit 版本 525 中提交的: https://bugs.webkit.org/show_bug.cgi?id=57600

并在 WebKit 版本 528 中解决(我认为这是因为在同一问题上打开了不同的回归错误): https://lists.webkit.org/pipermail/webkit-unassigned/2012-April/429252.html

但在 iPhone 设备上使用我的移动 Safari 时,重定向被拒绝,即使我有带有 WebKit 版本 534(更高版本)的移动 Safari。

有没有人遇到过这种行为,有解决办法吗?

注意:我确实定义了跨域 (CORS) 标头(因为它在 Google Chrome 和 Firefox 中工作)。

编辑:Windows 版 Safari 也存在同样的问题。

【问题讨论】:

    标签: ajax redirect safari cross-domain mobile-safari


    【解决方案1】:

    我在多个移动浏览器上遇到了同样的问题(SafariChrome/Dolphin Android)。

    302 没有解决方案,但我找到了解决方法:

    • 我们使用的 Java 框架可以重定向或转发 POST 响应,因此我们将其更改为 forwards 模式。

    使用转发会产生200,因此AJAX 成功处理程序(我们使用jQuery)可以正确检索数据。

    希望这会有所帮助。

    【讨论】:

    • 谢谢,在JSP中,我也可以转发请求,比如:getServletConfig().getServletContext().getRequestDispatcher("/JSP/Demo.hello.jsp").forward(request,response) ;但我仍然想重定向而不是将请求转发到 JSP 页面。
    猜你喜欢
    • 2015-05-13
    • 2014-12-30
    • 2016-01-07
    • 2013-10-19
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 1970-01-01
    • 2013-02-28
    相关资源
    最近更新 更多