This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
It is usually heplful to include the detailed error message.
However, in this case I can tell that you need to make sure that the string that is to be quoted in Javsscript has the quote characters escaped so that they do not confuse the Javscript parser. Much in the same way that you escape quotes in Java string literals.