WKWebView cannot start ajax to download file on local

I insert all html into WKWebView, everything works until I find out that WKWebView cannot load the XML file on the local

$ .ajax ({
        type: "GET",
        url: "tags.xml",
        dataType: "xml",
        cache: false,
        success: function (xml) {

        },
        error: function () {

            alert ("An error occurred while processing XML file.");
        }
    });

my code is for UIWebView

// urlFolder is located locally in a temporary file: tmp / www / htmlFolder 
// urlFile is located in the urlFolder: tmp / www / htmlFolder / index.html
// xml file is located in the urlFolder: tmp / www / htmlFolder / tags.xml


WKWebViewConfiguration * theConfiguration = [[WKWebViewConfiguration alloc] init];
    _webView = [[WKWebView alloc] initWithFrame: self.view.frame configuration: theConfiguration];
    [_webView loadFileURL: urlFile allowingReadAccessToURL: urlFolder];

    [self.view addSubview: _webView];

Note. I am using beta version of Xcode7.1, Objective-C, ios9.1, WKWebView

+4
source share
2 answers

From what I could find, they disabled cross origin requests in WKWebViews.

For more information about this problem, find the cors or xhr + WKWebView. I think this should be some kind of mistake, because it was always possible in "ordinary" UIWebViews using local files (for example, your example).

/ http- , . App Transport Security Settings .plist localhost.

+3

Source: https://habr.com/ru/post/1612218/


All Articles