iOS 7 javascript XMLHttpRequest bug

前端 未结 1 1090
旧时难觅i
旧时难觅i 2021-02-10 12:33

This post is half question - half announcement.. i develop iOS applications which include UIWebView that performs javascript code. When i run the app on devices with the newly

1条回答
  •  Happy的楠姐
    2021-02-10 13:11

    The UIWebview does not allow synchronous XHRs in IOS7.

    This is one of the frustrating differences between the WebView and Safari (which does allow them).

    The workaround:

    1. Create an Objective-C function that makes a synchronous HTTP request.

    2. Call that function from JavaScript. (This happens synchronously.)

    Of course, if you wanted any benefits like caching, you would have to implement that yourself.

    It's a bit baffling why Apple would think requiring that workaround is a good idea.

    0 讨论(0)
提交回复
热议问题