Send Java script variable to a controller

I am trying to build an application that has google maps. Inside the
script there are two java script variables. I want to send those two
variables using a java function. What is the best why to do that.
Could someone give me a simple example on that.

Here is non ajax method(but ajax pretty the same):
var f = document.createElement(‘form’); = ‘none’;
f.method = ‘POST’; #or get
f.action = this.href;
var m = document.createElement(‘input’);
m.setAttribute(‘type’, ‘hidden’);
m.setAttribute(‘name’, ‘_method’);
//m.setAttribute(‘value’, ‘delete’); #or put it depends of your needs
//Now we can send your variables:
var s = document.createElement(‘input’);
s.setAttribute(‘type’, ‘hidden’);
s.setAttribute(‘name’, ‘my_var’);
s.setAttribute(‘value’, ‘my_var_value’);