parseJSON with a string containing only a space

parseJSON with a string containing only a space

I'm using the jquery-ujs library with a Rails 3 project. Forms with a data-remote attribute get converted into an ajax request using  ajax(). In jQuery's internals, the response from the server is passed to  parseJSON() which, if the body is a whitespace only string, will raise a parser error. Rendering a response with `head(:ok)` will return a body containing only a single space and thus cause an error.

I don't have any trouble making the fix with tests and submitting a pull request, but I'd like to get an opinion on if this is a jQuery bug or a jquery-ujs bug. It's fixable in jquery-ujs by adding a dataFilter callback and calling trim() on the response, but my personal opinion is this may be better handled by jQuery since I imagine this issue isn't only limited to Rails. Especially since parseJSON() already calls trim() on the input right after the check for a null or empty string.