type error: cannot call method 'invoke procedure' of undefined in worklight

♀尐吖头ヾ 提交于 2019-12-29 09:50:21

问题


this is my js function...

var invocationData={
                adapter : 'Health_Care',
                procedure: 'update',
                    parameters:[uname,cp,np]
            };

            WL.Client.invokeProcedure(invocationData,
            {
                onSuccess: function(){
                     alert("Password successfully changed");
                },
                  onFailure: function(){
                      alert("failed");
                  }

            }       
            );

my adapter is...

var updateStatement = WL.Server.createSQLStatement("UPDATE EMPLOYEE SET PASSWORD=? WHERE UID=? AND PASSWORD=?");

function update(pid,curP,newP) {

return WL.Server.invokeSQLStatement({
    preparedStatement : updateStatement,
    parameters : [newP,pid,curP]

});

}

my adapter is alone working when i invoke adapter... but with java script i'm getting the above mentioned error for all the pages....


回答1:


Seems like you're trying to use Worklight features in other HTML pages without having all the required script tags (worklight.js, wlclient.js, etc.). Worklight is geared towards single page applications, if you want multiple HTML files make sure all the right JavaScript is getting loaded (look at the native folder, www/default/[appname].html in the head tag).

Here's an example: native/www/default/wlapp.html

<!-- Static App properties + WL namespace definition -->
<script src="wlclient/js/cordova.js"></script>
<script src="common/js/wljq.js"></script>
<script src="common/js/base.js"></script>
<script src="wlclient/js/messages.js"></script>
<script src="common/js/wlcommon.js"></script>
<script src="wlclient/js/diagnosticDialog.js"></script>
<script src="wlclient/js/deviceAuthentication.js"></script>
<script src="wlclient/js/window.js"></script>
<script src="wlclient/js/worklight.js"></script>
<script src="wlclient/js/wlclient.js"></script>
<!-- More script tags... -->

The JavaScript file that defines WL.Client.invokeProcedure is wlclient/js/wlclient.js.



来源:https://stackoverflow.com/questions/15629323/type-error-cannot-call-method-invoke-procedure-of-undefined-in-worklight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!