iosWebViewFix/example/test_assets/in_app_webview_fetch_test.html

40 lines
1.6 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>InAppWebViewFetchTest</title>
</head>
<body>
<h1>InAppWebViewFetchTest</h1>
<script>
window.addEventListener('flutterInAppBrowserPlatformReady', function(event) {
fetch(new Request("http://192.168.1.20:8082/test-download-file")).then(function(response) {
window.flutter_inappbrowser.callHandler('fetchGet', response.status);
}).catch(function(error) {
window.flutter_inappbrowser.callHandler('fetchGet', "ERROR: " + error);
});
fetch("http://192.168.1.20:8082/test-ajax-post", {
method: 'POST',
body: JSON.stringify({
firstname: 'Foo',
lastname: 'Bar'
}),
headers: {
'Content-Type': 'application/json'
}
}).then(function(response) {
response.json().then(function(value) {
window.flutter_inappbrowser.callHandler('fetchPost', value);
}).catch(function(error) {
window.flutter_inappbrowser.callHandler('fetchPost', "ERROR: " + error);
});
}).catch(function(error) {
window.flutter_inappbrowser.callHandler('fetchPost', "ERROR: " + error);
});
});
</script>
</body>
</html>