0

This is my first mobile application written in HTML5 + JavaScript with sqlite db. This is a login form: OK if user/pass is correct so I can land to 'main-page'.

I test locally with Firefox and Chrome, and it's all fine, then I use Intel XDK, running with USB connected in device (not remote), and it's still ok; but when I build with Intel XDK, install in my device, the login fails! I try to build in Phonegap, but it fails too. I don't know why, so please help.

var selectUserPass = "SELECT count(*) as ada FROM user2 where user=? and pass=?";
...
function masuk()
{ 
        var user1 = $('#user-login').val();
        var pass1 = $('#pass-login').val();
        db.transaction(function (tx) {
            tx.executeSql(selectUserPass, [user1,pass1], function (tx, result) {
                dataset = result.rows;
                item = dataset.item(0);
                if (item['ada']>0) location.href="periksa.html";
                //return false;
            });
        });
        
}

$(document).ready(function(){
       $("#masuk").click(function(){
            masuk();
        });
});  
<input type="text" id="user-login" name="login-email" autocomplete="off" class="form-control input-lg" placeholder="Username" />
<input type="password" id="pass-login" name="login-password" class="form-control input-lg" placeholder="Password" />
<button type="submit" id="masuk" class="btn btn-sm btn-primary"><i class="fa fa-check-circle"></i> MASUK </button>
Gargaroz
  • 313
  • 9
  • 28
  • What url to login? Do you deploy server in local? – Hanh Le Jul 28 '15 at 01:41
  • I only use javascript to access sqlite in my device (local), nothing to connect with another device (or 'server'). i'm login from index.html to periksa.html (if user,passwors is correct) with same folder. user and password save at sqlite in device. – M. Syamsul Arifin Jul 29 '15 at 02:11
  • Did query to db is success or fail when you login? You can log error when query fail: transaction.executeSql("",[],dataHandler, errorHandler); – Hanh Le Jul 29 '15 at 02:49

2 Answers2

0

Have you modified the config.xml to allow your program to call your server? If yes, probably you are missing the whitelist-plugin; without it your software can't call anything outside itself.

That is, check your config.xml and run cordova plugins add cordova-plugin-whitelist

Also, read this

OneZeroOne
  • 157
  • 1
  • 10
  • this application is not using server, it's only use local database (sqlite) in device, I only need saving data to my device with javacript. – M. Syamsul Arifin Jul 27 '15 at 10:21
  • I'm not sure, but maybe it because location.href not working at phoneGap or cordova framework, but I don't know how to write this at javascript :) – M. Syamsul Arifin Jul 27 '15 at 10:23
  • See [this answer](http://stackoverflow.com/questions/19300135/can-a-phonegap-app-access-localhost-upon-being-installed-on-device) because it seems to be similar to your problem. Do you have a server on your device? :) – OneZeroOne Jul 27 '15 at 12:28
0

this problem was solved when I build my HTML5, CSS and Javascript files in Crosswalk with IntelXDK (see : https://crosswalk-project.org/). But if compare with Android build, Crosswalk build has bigger file (APK file from android build has 1,7MB, but from crosswalk build has 20MB)