2015년 3월 10일 화요일

allow ajax header in Android webview and ios uiwebview

my application is hybrid app. both android and ios works.

local contents is loaded in apps. and add additional headers ajax server call.
In my work around , server modification not allowed.

local-content ajax add header. (ref http://stackoverflow.com/questions/3258645/pass-request-headers-in-a-jquery-ajax-get-call )

$.ajax({
    url: "/test",
    headers: {"X-Test-Header": "test-value"}
});

Android webview setting ( ref : http://stackoverflow.com/questions/8648616/webview-javascript-cross-domain-from-a-local-html-file )

Initialize your WebView:
WebView _webView = (WebView) this.findViewById(R.id.id_of_your_webview_in_layout);
get WebView settings:
WebSettings settings = _webView.getSettings();
set following settings:
settings.setJavaScriptEnabled(true);
settings.setAllowFileAccessFromFileURLs(true); //Maybe you don't need this rule
settings.setAllowUniversalAccessFromFileURLs(true);




ios

http://stackoverflow.com/questions/10838598/openallwhitelisturlsinwebview



댓글 없음:

댓글 쓰기

3gb minning

비트코인 골드 -- 마이너 다운로드 :  https://www.bminercontent.com/releases/bminer-v6.0.0-d111154-amd64.zip -- vcruntime140.dll 다운로드  https://www.micr...