How can I use relative urls in ajax requests within trigger.io apps on Android 4.4 (kitkat)?

痞子三分冷 提交于 2019-12-13 06:00:32

问题


My trigger.io-bundled jquery-mobile app works great on both android < 4.4 and iOS devices but refuses to load any relative pages, scripts etc. on android 4.4 once jquery mobile loads. Afaik, jqm turns all links to ajax requests, which suggests ajax requests are broken. WebView has been changed to be Chromium 30-based in kitkat and the migration guide mentions url handling as an area of breaking changes (second link below).

https://developer.android.com/about/versions/android-4.4.html https://developer.android.com/guide/webapps/migrating.html#URLs

There is at least one other person with a broken jqm/trigger.io app on android 4.4, see https://github.com/jquery/jquery-mobile/issues/6746 . I have put together a small app you can use to verify the issue: https://github.com/mnacos/jqm-kitkat

How do I get ajax requests working against relative urls again on android 4.4? Is there a way to control targetSdkVersion when building trigger.io apps for Android 4.4 (kitkat)? Is there a custom scheme defined in the trigger.io webview/browser which could help with relative links?


回答1:


Unfortunately the Android 4.4 WebView's URL canonicalization/normalization logic is a lot more conservative for non-standard[a] schemes. This is because the normalization of standard schemes assumes it can change the URL to lowercase, do %-encoding, etc.. which would break content:// URLs for example. If you look at the bug you've linked it seems like the root issue of the problem is jqm rewriting the urls to be content://// instead of content://.

I don't think it's likely resolving the 4 slashes meets the bar for an urgent fix in the WebView (you're welcome to file a bug on this if you disagree) so IMHO the best (and probably fastest) way to address this would be to work with the jqm team (or submit a pull request) to make jqm not add the extra 2 slashes to the URI.

[a] Chromium has a list of hardcoded "standard" schemes. These include http, https, ftp, etc. and it's essentially a list of schemes known to be compatible with the normalization algorithm.

Edit: unfortunately changing the targetSdkVersion won't help you in this case.



来源:https://stackoverflow.com/questions/20469514/how-can-i-use-relative-urls-in-ajax-requests-within-trigger-io-apps-on-android-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!