gpt4 book ai didi

javascript - 如何使用remoteFunction将JavaScript变量传递给Grails Controller

转载 作者:行者123 更新时间:2023-12-02 14:10:37 24 4
gpt4 key购买 nike

我正在使用grails 2.1.1。我有一个远程函数,我想通过g:remoteFunction传递多个Java脚本变量。但是没有js变量要传递给 Controller ​​。我的js变量带有下划线,无法识别。谁能帮我这个忙吗?!!!这是我在下面的尝试:

我的功能>>>

function addNewBill(){
var orgId = $('#aaOrgIdAaOrg').val();
var ccId = $('#costCenter').val();
if(orgId != null && orgId != "null" && orgId != "" && ccId != null && ccId != "null" && ccId != ""){
$('#ccModal').modal('hide');
${remoteFunction(action: 'createBill', params: [purchaseOrderId: purPoMstInstance.id, aaOrgIdAaOrg: orgId, costCenter: ccId], update: 'bill')}
}
}

最佳答案

当remoteFunction最终呈现jQuery函数时,您可以使用params选项,使用jQuery选择器或所需的Js vars或函数来包含变量。

这是一个例子。如您所见,params值只是一个字符串,但是在渲染器之后,它将被运行,因为那是js;)

<button type="button" onclick="${remoteFunction(controller: 'category', action: 'save', update: "eventsDiv",
params: '\'type=\' + myJSvar)}">
${message(code: 'default.button.save.label')}
</button>

关于javascript - 如何使用remoteFunction将JavaScript变量传递给Grails Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34389908/

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