Form submit handler to return form values as JSON.
function _form_test_submit_values_json($form, &$form_state) {
// This won't have a proper JSON header, but Drupal doesn't check for that
// anyway so this is fine until it's replaced with a JsonResponse.
print drupal_json_encode($form_state['values']);
drupal_exit();
}