I'm using IBM MobileFirst to create an app. I've created an HTTP Adapter and now I'm working on the invocation of the response within my main.js file. Here is the invokeProcedure call (the invocationData var calls the adapter and the procedure within that adapter):
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadSuccess(),
onFailure : loadFailure(),
});
Now, I've defined a loadSuccess() and a loadFailure() function (declared before the invocation) as such (simple for testing purposes):
var loadSuccess = function(result){
alert("success");
alert(result.invocationResult);
}
var loadFailure = function(result){
alert("failure");
alert(result.invocationResult);
}
However, while "success" and "failure" will flash, "result" is coming back as null. Every tutorial I have seen as used these methods with success, so I am confused as to why my similar implementation is not working. Furthermore, the invokeProcedure function seems to be calling and flashing the results of both the success and failure options!
My adapter returns an appropriate response when I just test that, so why isn't the invocation of the data working correctly? IBM documentation is not very clear, so I appreciate any and all suggestions!
EDIT:
I updated main.js to the following code:
function loadSuccess(result){
alert("success");
}
function loadFailure(result) {
alert("failure");
}
function testFunc(userid, password) {
var invocationData = {
adapter : 'myAdapter',
procedure : 'myProc',
parameters : [ userid, password ],
};
WL.Client.invokeProcedure(invocationData,{
onSuccess : loadSuccess,
onFailure : loadFailure
});
}
When I test my adapter, by simply calling it, the response is successful and contains all the response information I want. So why isn't onSuccess being called here?