0

我有一个带有remotefunction的javascript函数,在那个remotefunction中我想传递map有参数,我想在控制器操作中使用那个map变量,我不知道如何在ramotefunction的参数中传递它并使用它在那个特定的控制器动作中......

jQuery(document).ready(function(){
 alert("checking for checkbox");
 var countryId = document.getElementById("countryId").value;
    jQuery('#groupdelete').on('click', function(){
        var names = {};
        alert("*********");
        jQuery('input:checked').each(function() {
            alert(jQuery(this).attr("id"));
            if(jQuery(this).attr("id")) {
            var id=jQuery(this).attr("id")
            var costId = "c"+id
            var ntb = document.getElementById(costId).value;
            alert(ntb);
            names[id] = ntb;
            }   
        });
        alert(names[1]);
    })


    ${remoteFunction(action:'addLabServiceToCountry', controller:'country', params:'\'names=\'+names')}

})

params:'\'names=\'+names' which is not working properly, how to pass map variable in params of remotefunction and in contoller action how to access that.
4

1 回答 1

0

尝试这个:

${remoteFunction({action: "addLabServiceToCountry", controller: "country", params: names});

然后,remoteFunction()您需要遍历params以获取所有映射名称。

或者您可以转换names为字符串:

var namesStr = names.join(',');

然后传递字符串:

${remoteFunction({... , params: namesStr});
于 2013-09-13T11:43:35.260 回答