1

Initially Testing by user name only not the password. After successful login it gives login successful alert but cannot redirect to particular div or view(from mobile navigation IBM Worklight) on the same html page(YummyjQueryMobile145.html).

Tested codes like:

//#login > login button id
//#home > redirected div/view id

$(function(){
$("#login").click(function(){
                $("#home").load("YummyjQueryMobile145.html", function(){
                    alert("loaded!");
                });
            });
});

JS file

function Login()
    {
        //alert("Login");
        var invocationLogin={
                adapter:"SQL_ADAPTER_Yummy",
                procedure:"procedureLogin",
                parameters:[]
               };

    var optionsLogin={
            onSuccess:succLogin,
            onFailure:failLogin
            };
    WL.Client.invokeProcedure(invocationLogin,optionsLogin);
    }

    function succLogin(result)
    {
        //alert("succLogin");
        var LUname=$("#LUname").val();
        var LPass=$("#LPass").val();
        var flag=0;
        var n;

        var i,
        resultSet = result.invocationResult.resultSet;
        //alert(result.invocationResult.resultSet);
        namesArray = [];

        for (i = 0; i < resultSet.length; i++)
        {
        namesArray[i] = resultSet[i].NAME;
        }

        //alert (JSON.stringify(namesArray));

        for (i = 0; i < resultSet.length; i++)
        {
            n = LUname.localeCompare(namesArray[i]);
            if(n==0)
            flag=1;
        }

        if(flag==1)
            {
            alert("Login Successful");
            //Here the Redirect code/same html page to a particular div or view
           //clicking login button if success then redirect to home div/view

            }
        else
            alert("Try Again!!!");

    }

    function failLogin(result)
    {
         alert(result+"try again Login");
    }

HTML

....
<div class="bg" id="LogIn" data-role="page" data-add-back-btn="true"
data-back-btn-text="Home" data-theme="b">
....
<a href="#" data-role="button" id="login" data-theme="a" onclick="Login()">Log In</a>
....
<div class="bg" data-role="page" id="home" data-theme="b">
....

1 Answers1

2

You can use window.location like :

window.location='same_page_url#id_of_the_div';
Brijesh Bhatt
  • 3,810
  • 3
  • 18
  • 34