Search code examples
ibm-mobilefirstmobilefirst-adapters

Passing value from textbox to http adapter failed mobilefirst platform


I'm trying to pass some values from a textbox to an http adapter and it have the following error:

Here is the index.html

  Username:<br>
   <input type="text" name="username" id="username"><br>
    Password:<br>
   <input type="text" name="password" id="password"><br>

    <button onclick="mobgetVerify()">Login</button>
    <p> 
    <p id="demo"></p> <br />        
    <br />
    <br />

mains.js

function mobgetVerify() {

   alert("Hi" + $('#username').val() + $('#password').val());
    var invocationData = {
           adapter : 'LoginAdapter',
           procedure : 'getVerify',
           parameters : [ $('#username').val() , $('#password').val() ]
    };

    WL.Client.invokeProcedure(invocationData, {
           onSuccess : getVerifySuccess,
           onFailure : getVerifyFailure,
    });
};

 function getVerifySuccess(res) {


        var httpStatusCode = res.status;
        if (200 == httpStatusCode) {
               var invocationResult = res.invocationResult;
               var isSuccessful = invocationResult.isSuccessful;
               if (true == isSuccessful) {

                   $("#demo").html(JSON.stringify(res.responseJSON.data));   

          if (res.responseJSON.data== "True "){
                         window.location="pages/view.html";
                     }

                     alert("Success: Value= " + res.responseJSON.data);



               } else {
                     alert("Error. isSuccessful=" + isSuccessful);
               }
        } else {
               alert("Error. httpStatusCode=" + httpStatusCode);
        }

};

function getVerifyFailure(result){
    alert("Verification Failure");
};

I would highly appreciate if i can get some help. Thank you.


Solution

  • The provided sample application worked just fine... I received an alert dialog with the text: "Success: Value=False".

    The only difference I can think of, which relates every time in each of your questions... if the IP address. In your provided LogCat, it shows the server's IP address is "10.0.0.3", whereas mine is my actual IP address (9.148.x.y in my case).

    As you were previously advised - use the correct IP address of the server in wlclient.properties.

    To check for mine, I typed the following in Terminal: ifconfig (in Windows - "ipconfig").