Sunday, 10 January 2016

XML : Saving to Google Drive: InvalidCharacterError: Failed to execute 'btoa' on 'Window' Quotes

I have a web app that saves users' data to their Google Drive. Some text strings that get saved come from xml files that are loaded dynamically via AJAX call. When the string contain quote marks like this: "sometext" -- the “ and ” my JS code

   var base64Data = btoa(JSON.stringify(newObj))    

throws the exception:

  "InvalidCharacterError: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."     

QUESTIONS:

  1. Are these not Latin1 characters?
  2. Since I cannot change XML files, I need to change them once they hit my page. Is there an easy CSS method of doing this? Or do I need a javascript solution? (I can do this, but was hoping there was a more elegant solution)
  3. The xml files are loaded via AJAX call, is there clean data returned from an ajax call to only use "" marks ?

No comments:

Post a Comment