I am trying to create a android app with phonegap, the first page is the login page, it queries to a server for user authentication, the server returns json string: true if the login is successful or false otherwise. I am getting the response but i am not able to redirect to next html page. I am using the below code
$('#loginForm').submit(function(){
var uid = $('#login').val();
var pwd = $('#password').val();
$.getJSON('http://example.com/phonegap/login.php',
{ userid: uid, password: pwd },
function(json) {
$.each(json, function(k, v) {
if(v == "true" || v == true){
super.loadUrl("file:///android_asset/www/page2.html");
} else {
$('#loginError').html("Login failed, username and/or password don't match");
}
});
});
return false;
});
Please let me know, how can I redirect the user to page2.html after successful login?
You can call other html pages using window.location and if your second html page present in www folder dont give full path (Please remove your native way path). Please check out following code.
$('#loginForm').submit(function(){
var uid = $('#login').val();
var pwd = $('#password').val();
$.getJSON('http://example.com/phonegap/login.php',
{ userid: uid, password: pwd },
function(json) {
$.each(json, function(k, v) {
if(v == "true" || v == true){
window.location="page2.html";
} else {
$('#loginError').html("Login failed, username and/or password don't match");
}
});
});
return false;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With