cómo pasar parámetros en función remota

I have a javascript function with remotefunction,,, in that remotefunction i want to pass map has parameter and i want to use that map variable in controller action,, i don't know how to pass that in params of ramotefunction and to use it in that particular controller action...

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.

preguntado el 13 de septiembre de 13 a las 12:09

1 Respuestas

Prueba esto:

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

Entonces en remoteFunction() you need to iterate through params to get all mapped names.

Or you can convert names a una cuerda:

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

and then pass the string:

${remoteFunction({... , params: namesStr});

Respondido el 13 de Septiembre de 13 a las 13:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.