【发布时间】:2016-06-07 04:43:48
【问题描述】:
您好,我在点击/点击事件中遇到了一个 ajax 请求问题,该事件在 android webview 上不起作用。如果我在设备上使用 chrome 运行我的 webapp 链接,并且 pc 一切正常。我在删除 ajax 函数后尝试了该函数,然后重定向在我的应用程序中起作用。其他 ajax 请求在应用程序中工作正常。它看起来像里面的东西或者 ajax 函数对此负责。我使用 jquery mobile 1.4.5
我的活动中的 webview 设置:
CookieManager.getInstance().setAcceptCookie(true);
mWebView = (WebView) findViewById(R.id.webview);
// Brower niceties -- pinch / zoom, follow links in place
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.setWebViewClient(new GeoWebViewClient());
// Below required for geolocation
mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
mWebView.getSettings().setAllowUniversalAccessFromFileURLs(true);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setGeolocationEnabled(true);
mWebView.setWebChromeClient(new GeoWebChromeClient());
sn-p 我的页面
<ul data-role="listview" class="ul" id="uItem1" data-inset="true">
<?php foreach ($result as $key => $row): ?>
<li data-icon="false" class="listitem<?php echo $row['id']; ?>">
<a type="button" id="<?php echo $row['id']; ?>">
<h2>test</h2>
</a>
</li>
<script>
$(".listitem<?php echo $row['id']; ?>").on('tap', function() {
var chatid = <?php echo $row['id']; ?>;
$.ajax({
url: 'read.php',
data: {
chatid
},
type: 'POST',
success: function(output) {
alert(output);
}
});
window.location.href = 'chatview.php';
});
</script>
<?php endforeach; ?>
</ul>
【问题讨论】:
标签: javascript android jquery ajax jquery-mobile