There are two ways to access code behind from the client.
- Store it in a collection sent with a request (normally this is through a form submit).
- Set up an "AJAX" call to a server side service through JavaScript.
There are variations on the above, but essentially you are consuming a service or you are posting back.
Looking at your code, you want the AJAX direction. I would start with this Stack Overflow postthis Stack Overflow post, as it covers the basics of passing an array back to the "service endpoint" of a code behind file.