gpt4 book ai didi

javascript - 将参数传递给适配器时出现问题

转载 作者:行者123 更新时间:2023-12-03 12:02:32 25 4
gpt4 key购买 nike

我有一个登录表单,其中包含用户名和密码。当用户点击提交按钮时,调用以下js函数。

function getGeoCode(){
var para=[$('#usernameInputField').val()];
alert("from sql adapter"+para);

var id = {username : para };
var invocationData = {
adapter: "GDMSDbAdaptor",
procedure: "getGeoCode",
parameters: [id]
};
alert("before adapter proc call");

WL.Client.invokeProcedure(invocationData, {
onSuccess: getMessage,
onFailure: getMessageOnfailure
});
alert("after adapter proc call");
}

下面的适配器代码在上面的函数之后执行

var procedureStatement = WL.Server.createSQLStatement("SELECT DISP_NUMBER,DISP_STATUS,DISP_CREATE_DATE,CUST_CONT_NAME,DISP_RES_OWNER,DISP_MANAGER FROM GDMW.DISPUTE WHERE DISP_RES_OWNER IN (SELECT USER_CNUM FROM GDMW.USER_ACC_PROFILE WHERE USER_EMAIL=?)");

function getGeoCode(data) {
var email=data.username;

WL.Logger.info("In getGeoCode method"+email);
return WL.Server.invokeSQLStatement({
preparedStatement : procedureStatement,
parameters : [email]
});
}

运行上述代码时出现以下错误

[ERROR ] FWLSE0099E: An error occurred while invoking procedure [project GDMSLoginApp]GDMSDbAdaptor/getGeoCodeFWLSE0100E: parameters: [project GDMSLoginApp] TypeError: Cannot find default value for object. (C%3A%5Cnewworkspaceworklight%5CGDMSLoginApp%5Cadapters%5CGDMSDbAdaptor/GDMSDbAdaptor-impl.js#22) FWLSE0101E: Caused by: [project GDMSLoginApp]nullorg.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object. (C%3A%5Cnewworkspaceworklight%5CGDMSLoginApp%5Cadapters%5CGDMSDbAdaptor/GDMSDbAdaptor-impl.js#22)

但是当我硬编码如下参数(电子邮件 ID)时它工作正常:

function getGeoCode(){
var para=[$('#usernameInputField').val()];
alert("from sql adapter"+para);

var id = {username : 'some@email.address' };
var invocationData = {
adapter: "GDMSDbAdaptor",
procedure: "getGeoCode",
parameters: [id]
};

alert("before adapter proc call");
WL.Client.invokeProcedure(invocationData, {
onSuccess: getMessage,
onFailure: getMessageOnfailure
});
alert("after adapter proc call");
}

这与单引号有关吗?

最佳答案

我的第一个猜测是发生这种情况是因为您使用了括号:

var para=[$('#usernameInputField').val()];

当你不应该:

var para=$('#usernameInputField').val();

你也可以这样做:

var id = {username : $('#usernameInputField').val() };

关于javascript - 将参数传递给适配器时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25348005/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com