Updating a database record using Javascript variables

I need to update a record in a table based on a event that occurs in the
View. I believe the update action should occur in the controller. I
think I need to call the controller action from the View and pass data
that is stored in a Javascript variables as a parameter, but I am not
sure how to do it. Can someone show me how I should be doing this?

Below is a simplified version of the code I am trying to produce:

View:

Controller:
Def updatex
Person.update(10, {:xvalue => params[:xvalue]})
end