type error:无法在worklight中调用undefined方法'invoke procedure'

时间:2013-03-26 04:19:37

标签: adapter ibm-mobilefirst

这是我的js功能...

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");
                  }

            }       
            );

我的适配器是......

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

功能更新(pid,curP,newP){

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

});

}

当我调用适配器时,我的适配器单独工作...但是使用java脚本我得到了所有页面的上述错误....

1 个答案:

答案 0 :(得分:2)

似乎您尝试在其他HTML网页中使用Worklight功能而没有所有必需的脚本标记(worklight.jswlclient.js等)。 Worklight面向单页面应用程序,如果您想要多个HTML文件,请确保加载所有正确的JavaScript(查看头标记中的本机文件夹www/default/[appname].html)。

以下是一个示例: 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... -->

定义WL.Client.invokeProcedure的JavaScript文件是wlclient/js/wlclient.js