Christian Moen
Christian Moen

Reputation: 1301

jQuery ajax call can't decode to uft-8 charset from webpage into Chrome Extension after chrome update

I've previously created a extension for google chrome were I grabbed a chat from a webpage using jquery ajax and displayed a more nicer way within the extension popup. Now, every æ ø å character is displayed with the unicode error �.

I know that both me and the site hasn't done anything new or changed the charset. They still got their charset defined in the header, and the correct characters is displayed on their page.

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

Of course I'm using the uft-8 charset on my extension, but this hasn't been a issue before now..

I've tried to define both uft-8 and ISO-8859-1 as content type in my ajax call.. Now i'm getting a bit clueless on this issue. The charset errors only include the chat, everything else is in its current state as it has been from the start.

Screenshot from the extension

Whole source code is located at: https://github.com/Cmoen11/GS-Chat-Chrome-Extension

Interesting files: index.js and index.html

Upvotes: 2

Views: 323

Answers (1)

plonknimbuzz
plonknimbuzz

Reputation: 2664

just change your mime with event beforeSend

function fetchData()
...
timeout: 10000,
        contentType: 'Content-type: text/plain; charset=iso-8859-1',
        beforeSend: function(jqXHR) {
            jqXHR.overrideMimeType('text/html;charset=iso-8859-1');
        },
        success: function (newRowCount) {

...

reference: https://stackoverflow.com/a/14397845/3396168

Upvotes: 2

Related Questions