1 Reply Latest reply on Apr 28, 2016 8:06 AM by kerrishotts

    onload redirect if (input == 'success')


      when a user logs in too my app my server verifys their account and returns success or failed depending on if they get their login details correct


      so here I have a div called redirect and sets a value of either success or failed:


      +'<div type="submit" id="redirect" value="'+data.redirectvalue+'"</div>'


      and here I have javascript which when the page loads it checks that div and if the value is success it will take them to their page or if anything else it will alert failed:


         function onLoad() {

                      document.addEventListener("deviceready", onDeviceReady, false);



              var input = document.getElementById('redirect');


              function onDeviceReady() {

                  if (input == 'success') {

                      window.location = "myPage.html";

                  }else {





      but when ever i try logging in i always get the alert failed even though i have actually logged in successfully,

      heres a screen shot of the alert:

      Screen Shot 2016-04-27 at 22.46.35.png


      and when i click ok i still get my success page which is what ive previously buil, i rely on this becuase this does actually give me green page for success or red page for failed, as you can see i am getting my green page for successful login:

      Screen Shot 2016-04-27 at 22.46.43.png


      anyone got any ideas whats wrong with my code?


      thanks in advance!

        • 1. Re: onload redirect if (input == 'success')
          kerrishotts Adobe Employee

          1. I don't think you've provided enough code to help. It would help to see more of the file in which your first line of code appears (data.redirectvalue).


          2. The alert you indicate in the screenshot is not the same alert you show code for. Note that the screenshot says "error", but the code you show would alert "failed"


          3. You appear to be using a multi-page architecture for the app. I would advise against doing so. Instead you should look into creating a single-page architecture app. Since you're currently using the MPA style, you should indicate filenames alongside your code samples so we have an idea exactly where your code lives.


          4. Just a tip: == will coerce types. If you want true equality, use ===. True inequality would be !==.