How do I remove extra space in table field? I'm using Views Module. I created a new ContentType with 3 custom fields: (text)Criteria, (decimal)Monthly, (decimal)Semester.

I created a table style view that retrieved the ContentType I created and dropped the values into a table. I'm actually using Javascript to grab the contents of each row generating a JSON array of objects with key-value-pairs for the content of the table, then I'm doing some fancy Javascript rendering. It's just a quick way to leverage Drupal's views and get the data where I want it exactly.

Anyway, when I grab the content of the Title row, $(this).find('td.views-field-title a').text();, it works fine, but when I try the exact same thing with the other 3 rows, I end up with a lot of space and \n. So my object ends up looking like:

[
 {'title':'Correct Title','criteria':'\n     Criteria Title    ','monthly':'\n     $70.00     '},
 {...},
 {...}
]


I can't figure out where the \n and extra space is coming from. It seems to be how the view formats the fields. How can I get rid of those?

Note: I do have the fields set to Plain Text in the configuration.
I checked this in my site and this is indeed default behaviour of Views. The easiest way to fix this is by changing your code to:

$.trim($(this).find('td.views-field-title a').text());