Call a controller action from javascript with POST parameters

I want to implement “update project participants” functionality by means of CGridView. I list all users and then I have a CCheckBoxColumn. Rows of those users that participate in the project are checked. I managed to get in javascript the array of the checked rows. Now I want to call a controller action passing that array as a parameter. How can I do this?

Thanks

Not sure if this can be done or not. However, could you use a string instead? You can pass all id of rows that are checked as a string and separate them with certain character, like: ‘ID1 | ID2 | ID3’.

jQuery style:


$.post(

    '<?php echo $this->createUrl("your route here")?>', 

    {'ids[]' : id_array}, 

    function (data) {

        // Analyze responce here

    }

);

http://api.jquery.com/jQuery.post/

View the examples

On PHP side you get a nice array in $_POST[‘ids’] of all ids you have selected.

Thank you very much.