.load()函数在带有webview的Android应用程序上运行

.load()函数在带有webview的Android应用程序上运行,android,jquery,webview,Android,Jquery,Webview,我想用HTML、CSS和jQuery创建一个Android应用程序。 我曾尝试用这种方法实现jQuery的.load()函数。它可以在浏览器上工作,但不能作为Android应用程序。是否还有其他解决方案,例如AJAX $(document).ready(function() { $('#nav li a').click(function(){ var toLoad = $(this).attr('href')+' #content'; $('#content').hide

我想用HTML、CSS和jQuery创建一个Android应用程序。 我曾尝试用这种方法实现jQuery的
.load()
函数。它可以在浏览器上工作,但不能作为Android应用程序。是否还有其他解决方案,例如AJAX

$(document).ready(function() {

  $('#nav li a').click(function(){

    var toLoad = $(this).attr('href')+' #content';
    $('#content').hide('fast',loadContent);
    $('#load').remove();
    $('#wrapper').append('<span id="load">LOADING...</span>');
    $('#load').fadeIn('normal');
    function loadContent() {
      $('#content').load(toLoad,'',showNewContent())
    }
    function showNewContent() {
      $('#content').show('normal',hideLoader());
    }
    function hideLoader() {
      $('#load').fadeOut('normal');
    }
    return false;

  });
});
}))

我找到了一个解决方案: 函数getContent(href){

$.ajax({
键入:“获取”,
//url:href+“.html”,
//url:“http://localhost/ProVid/“+href+”.html”,
url:“http://webuser.hs-furtwangen.de/~lieneman/pages/“+href+.html”,
//url:“http://webuser.hs-furtwangen.de/~lieneman/pages/vorstellung.html“,
数据类型:“html”,
发送前:函数(xhr){
xhr.overrideMimeType(“text/html;charset=ISO-8859-1”);
},
成功:解析HTML,
错误:函数(xhr、ajaxOptions、thrownError){
警报(xhr.状态);
$(“#content”).html(“Es ist ein Fehler aufgetreten”);
}
});
}

但您还必须知道,这只适用于像xampp这样的Web空间或虚拟Web空间,您必须使用“#”到href属性。

您是在使用Android浏览器查看还是在嵌入某种webview?这是一个带有eclpise as IDE的webview查看本文:在webview中出现JavaScript错误时,它会显示控制台消息。它有助于在WebView案例中调试JS。这也可能有帮助:我不确定,但我认为JS中没有错误。我在网上找到了不同的方法和解决方案。
$(document).on('pageinit', function() {
// handle menu clicks
$("ul#nav li a").click(function() {
    var page = $(this).attr("href");
    $("#content").load(page + ".html");

});
    $.ajax({
        type : "GET",
        //url: href + ".html",
        //url : "http://localhost/ProVid/" + href + ".html",
        url: "http://webuser.hs-furtwangen.de/~lieneman/pages/" + href + ".html",
        //url: "http://webuser.hs-furtwangen.de/~lieneman/pages/vorstellung.html",
        dataType : "html",


        beforeSend : function(xhr) {
            xhr.overrideMimeType("text/html; charset=ISO-8859-1");
        },
        success : parseHTML,

        error : function(xhr, ajaxOptions, thrownError) {
            alert(xhr.status);


            $('#content').html("<h3 style='text-align: center;'>Es ist ein Fehler aufgetreten</h3>");

        }
    });

}