I am trying to create a json object from variables that I am getting in a form.
var firstName = $(\'#firstName\').val();
var lastName = $(\'#lastName\').va
var formValues = {
firstName: $('#firstName').val(),
lastName: $('#lastName').val(),
phone: $('#phoneNumber').val(),
address: $('#address').val()
};
Note this will contain the values of the elements at the point in time the object literal was interpreted, not when the properties of the object are accessed. You'd need to write a getter for that.