Failed to execute ‘setRequestHeader’ on ‘XMLHttpRequest’: String contains non ISO-8859-1 code point.

When the front-end page sends a request to the background, non-english is put into the request header, so there will be coding format problems

Error message:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Failed to execute ‘setRequestHeader’ on ‘XMLHttpRequest’: String contains non ISO-8859-1 code point.
Failed to execute ‘setRequestHeader’ on ‘XMLHttpRequest’: String contains non ISO-8859-1 code point.
Failed to execute setRequestHeader on XMLHttpRequest’: String contains non ISO-8859-1 code point.

 

Solution:

Encoding: encodeURIComponent(str)
decoding: decodeURIComponent(str)

Read More: