When I pull data from a source with Javascript I don't have an issue with single quotes, but when I go to save data and it has a single quote the ajax call fails.

I don't want to have to save this to the database: I'm happy!

I want to safely pass the string through with the single quote and preserving it in the database. What's the best method for this?