0
votes

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>

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..

Thanks.

1
This can happen if the internet connection is unstable or very slow.Demonick
@Dev, Do you face this error debugging on a real device or an android emulator?Ata Iravani
I have solved this issue by adding the jquery,Jquery Mobile directly in to my project instead of referring it from CDNDev
@Dev can you please paste your code here or even give reference or link to site which helped to get your answerandroid developer
yes, sure...below is the answer..Dev

1 Answers

1
votes

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>

Thanks.