Doesn't redirect from one html page to another html page

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
Hi Team,

I am developing application phone gap+android, In that project I want to check authentication details from web, If success means i want to go success page,
but after getting the result doesn't display success page for me.

please tell solution for my problem.

My code,

HTML:

Username:
Password:


javascript:

function check_auth() {
var data_uname = jQuery('#uname').val();
var data_upwd = jQuery('#upwd').val();
alert('data_uname : '+data_uname+'data_upwd:'+data_upwd);

jQuery.ajax({
type : 'POST',
url : 'http://112.324.0.22:8080/WebAcess/Aut...',
data : {
'uname': data_uname,
'upwd': data_upwd
},
dataType:'json',
success : function(data) {

var postObject = eval('(' + JSON.stringify(data) + ')');

auth_res = postObject.res;

if(auth_res =='Success'){
alert("Success");
window.open("success.html",'_self');

//window.location="success.html";

}else{
alert("Failure");

window.open("failure.html",'_self');

//window.location="failure.html";

}
},
error : auth_err
});
}

Thank you,
Siva.
Photo of gudluri siva

gudluri siva

  • 62 Posts
  • 0 Reply Likes

Posted 8 years ago

  • 1
Photo of gudluri siva

gudluri siva

  • 62 Posts
  • 0 Reply Likes
Hi Team,

Still I didn't get response from phone gap support,

I wrote well code, but its not working properly.

please tell any other way for this requirement.

Thank you,
Siva.
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Is there any particular reason you are using 'window.open'? In a normal browser, this would open a new browser window, but this doesn't really exist in PhoneGap *(see note below). It seems like you are trying to redirect -- so you should use window.location.href = "success.html".

* Note: If you want to open in a new window, check out the ChildBrowser Plugin.
Photo of Sandeep Kamboj

Sandeep Kamboj

  • 1 Post
  • 0 Reply Likes
use (new Function("return "+jsonstring))() instead of eval();
Photo of ismael jimoh

ismael jimoh

  • 4116 Posts
  • 192 Reply Likes
Thanks for sharing this believe it will be useful to the community for reference.

However this is an old issue so will proceed to close this note.
Photo of vinayak

vinayak

  • 9 Posts
  • 0 Reply Likes
please share the code for login in phonegap