Android的,的PhoneGap和jQueryMobile - 错误与服务器的连接不成功" WWW /资产/ index.html的"

问题描述:

我曾尝试以下code和我得到错误的连接服务器失败,以WWW /资产/ index.html的

I have tried following code and I am getting error Connection to server was unsuccessful to "www/assets/index.html"

<!DOCTYPE html>
<html>
   <head>
     <style type="text/css">
        li span
         {
            font-weight: normal;
         }
     </style>
   <title> Sample App using jQuery Mobile</title>
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
      <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
      <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
   <head>
   <body>
      <div data-role="page" id="car">
         <div data-role="header" data-postion="fixed">
            <h1> Cars</h1>
            <h1 id="blogheader">Loading...</h1>
         </div>
         <div data-role="content">
            <ul data-role="listview" data-inset="true" id="contentListView">
            </ul>
         </div>
         <div data-role="footer" data-position="fixed">
             <h1> Footer </h1>
         </div>
     </div>

 <script type="text/javascript" charset="utf-8">
    $(function(){
       var serviceUrl='http://mysite:81/Service.asmx/ShowListViewData';
       $.ajax({
         url:serviceUrl,
         success:function(xml){
         setTimeout(
         function(){
            $(xml).find( "newset" ).each(function(){
                carName  = $(this).find('ItemName').text();
                description  = $(this).find('ItemDescription').text();
                $('#contentListView').append('<li><a href="#"><h3>Car type:<span> '+carName+'</span></h3><p>' + description + '</p></a></li>');
            });
        $('#contentListView').listview('refresh');
       }
       ,100);
      },
       error:function(){
      },
       dataType:"xml"
   });
 });
 </script>
 </body>
</html>

有趣的事实是它是工作的罚款更早。但现在我得到这个错误。逸岸我甚至试过这种方法[ super.setIntegerProperty(loadUrlTimeoutValue,60000); ],但没有得到解决。它消除了错误,但是从远程服务器中的数据是不是loading..Please帮助我..

the interesting fact is it was working fine earlier. But now I am getting this error. Infact I have even tried this approach[super.setIntegerProperty("loadUrlTimeoutValue", 60000); ], but not solved. It removes the error, but the data from remote server is not loading..Please help me..

感谢。

对不起,我迟到reply..here是code..the唯一不同的是我已经包括了所有的CSS和JS文件到我的项目比从CDN引用

Sorry for the late reply..here is the code..the only difference is i have included all the css and js files into my project than referring from CDN

<!DOCTYPE html>
<html>
   <head>
     <style type="text/css">
        li span
         {
            font-weight: normal;
         }
     </style>
   <title> Sample App using jQuery Mobile</title>
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
     <link href="styles/jquery.mobile-1.0.min.css" />
    <script src="scripts/jquery-1.6.4.min.js"></script>
   <script src="scripts/jquery.mobile-1.0.min.js"></script>
  <head>
   <body>
      <div data-role="page" id="car">
         <div data-role="header" data-postion="fixed">
            <h1> Cars</h1>
            <h1 id="blogheader">Loading...</h1>
         </div>
         <div data-role="content">
            <ul data-role="listview" data-inset="true" id="contentListView">
            </ul>
         </div>
         <div data-role="footer" data-position="fixed">
             <h1> Footer </h1>
         </div>
     </div>

 <script type="text/javascript" charset="utf-8">
    $(function(){
       var serviceUrl='http://mysite:81/Service.asmx/ShowListViewData';
       $.ajax({
         url:serviceUrl,
         success:function(xml){
         setTimeout(
         function(){
            $(xml).find( "newset" ).each(function(){
                carName  = $(this).find('ItemName').text();
                description  = $(this).find('ItemDescription').text();
                $('#contentListView').append('<li><a href="#"><h3>Car type:<span> '+carName+'</span></h3><p>' + description + '</p></a></li>');
            });
        $('#contentListView').listview('refresh');
       }
       ,100);
      },
       error:function(){
      },
       dataType:"xml"
   });
 });
 </script>
 </body>
</html>

感谢。