@variable returns in the wrong format after an ajax call

Does anyone knows how I can influence the format of the instance variable when it is returned after an ajax call. At the moment when I try to render it I get the error:- incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)

This happens when the instance variable is being rendered in the index.js.erb file.

It seems that the format.js is returning the @variable in the wrong format.