android - Error "The connection to the server was unsuccessful." in Cordova and jQuery -


i created app android using cordova , jquery mobile. works when test run code using google chrome, when try run on android emulator using android studio in cmd (locate>cordova emulate android) doesn't work.

when try run on emulator get:

"the connection server unsuccessful. (file:///android_asset/www/index.html)"

but if don't use jquery, works fine. didn't modify code in jquery or jquery mobile.

    <head>         <-- import jquery , codovar -->         <link rel="stylesheet" href="./css/jquery.mobile-1.4.5.min.css" />          <-- if remove 3 line of code below program working same open google chrome -->         <link rel="stylesheet" href="./css/jquery.mobile-1.4.5.min.css" />         <script src="./js/jquery-2.1.4.min.js"></script>         <script src="./js/jquery.mobile-1.4.5.min.js"></script>         <--end remove here -->          <script type="text/javascript" src="./js/login.js"></script>      </head>      <body>         <div data-role="page" id="page1">             <div data-role ="header" style="background-color: #00cca5;">                 <h1 style="color: #faf0ba; text-shadow: none; text-align: center;">login</h1>             </div>             <div data-role ="main" class="ui-content"  >                 <div align="center">                     <label>id:</label>                     <input type="text" id="login_id">                     <br>                     <label>password:</label>                     <input type="password" id="login_password">                     <div id="wrong" style="color: red;"><br></div>                 </div>                 <button style="background-color: #faf0ba; color:#00cca5;" data-role ="button" data-icon ="forward" id="let_login">log in</button>             </div>         </div>         <script type="text/javascript" src="cordova.js"></script>     </body> </html> 

and here login.js

$(document).ready(function () {     $("#let_login").on("tap",             function () {                 var id = $("#login_id").val();                 var password = $("#login_password").val();                 if (id == "test" && password == "password") {                     document.location.href = "./customer.html";                     //$.mobile.changepage("./customer.html");                 }                 else {                     $("#wrong").html("wrong id and/or password");                  }             }); }); 

and here mainactivity.java (modified file after read old post still doesn't work)

public class mainactivity extends cordovaactivity {     @override     public void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);          //modify line below         super.setintegerproperty("loadurltimeoutvalue", 70000);         //end modify line           // set <content src="index.html" /> in config.xml         loadurl(launchurl);     } } 

ps. first time using cordova , jquery

i recommend first, check config.xml there section can specify start page of app. must ponting "index.html" , think page called "login.html" (just guess) section looks this

<content src="your_page.html" />

just change section , try. if section set correctly, approach mohhamed imran n works, have tested it. hope helps.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -