小编Paw*_*eet的帖子

Ajax 在 android webview 中不起作用

我正在 webview 中加载一个网站,我们在网站中使用了 Ajax,它在 web 浏览器和移动浏览器上也能正常工作,但在 android webview ajax 不起作用,控制台中没有错误。这是我的代码:-

public class Activity_WebView extends AppCompatActivity implements  
 ConnectivityReceiver.ConnectivityReceiverListener {
WebView webview;
ProgressDialog pro_dialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);

    webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setPluginState(WebSettings.PluginState.ON);
    webview.setWebViewClient(new loadinsame());
    pro_dialog = new ProgressDialog(Activity_WebView.this);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.getSettings().setDomStorageEnabled(true);
    webview.getSettings().setAllowUniversalAccessFromFileURLs(true);

    boolean connection = checkConnection();
    if (connection) {
        webview.loadUrl("website url");
    } else {
        Toast.makeText(Activity_WebView.this, "Sorry! Not connected to 
       internet", Toast.LENGTH_SHORT).show();
        dialog_Show(webview, "Please check you Inernet connect and Reload.", 
        false);
    }
}

@Override
public void onNetworkConnectionChanged(boolean isConnected) { …
Run Code Online (Sandbox Code Playgroud)

ajax android webview android-webview

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

ajax ×1

android ×1

android-webview ×1

webview ×1